我不确定错误是作为语法检测到的

时间:2018-09-17 19:45:42

标签: python-3.x

print("You arrive at an open cavern and see two piles near the back.")
decision = input("Do you want investigate the left pile or the right pile?")
if decision == "left":
    difficulty += 1
if decision == "right":
    difficulty += 3
if difficulty <= 5:
    print("As you approach the pile you notice that its a pack that was dropped by an adventurer.")
    print("The pack has a sword that might come in useful.")
    ATK += 100
if difficulty >= 6:
    print("As you approach the pile you notice that its moving up and down slowly.")
    print("The pile is actually a", (colored("goblin!", "green"), "it jumps at you, ready to fight.")
    decision = input("Dou you strike left or right?")
    if decision == "right":
        print("The goblin jumps straight into your fist, which knocks it into a 
wall.")
        GOLD += 20
    if decision == "left":
        print("The goblin jumps onto you and scratches your face a few times 
before you throw it into a wall.")
        HP -= 150
        GOLD += 10
    print("The goblin is unconcious.")
print("You continue down the hallway.")

我不确定发生了什么,这表明存在语法错误。如果您运行代码,则在需要了解错误消息以提供帮助时,应该给出错误消息。

1 个答案:

答案 0 :(得分:0)

替换行

print("The pile is actually a", (colored("goblin!", "green"), "it jumps at you, ready to fight.")

使用

print("The pile is actually a", (colored("goblin!", "green")), "it jumps at you, ready to fight.")