这段代码在不同的脚本中使用时,我一直在修补它几个小时试图弄清楚什么是错的。继续收到错误说if语句错误但我没有看到任何错误。我为任何不合适的空间梳理了编辑器:
def shore_choice():
print
print "Enter 1 to take the path to the east."
print "Enter 2 to head to the west along the shore."
print "Enter 3 to head up the beach to the tall grass in the south."
x = 1
while x == 1:
choice = int(raw_input("Enter choice here: ")
if choice == 1:
time.sleep(2)
print name + " heads along the shore to the east"
x = 2
elif choice == 2:
time.sleep(2)
print name + " walks along the shore to the west"
x = 2
elif choice == 3:
time.sleep(2)
print name + " ventures up the beach towards the tall grass"
x = 2
else:
time.sleep(2)
print "I can't even right now"
x = 2
shore_choice()
我得到的错误是:
File "shorechoice.py", line 9
if choice == 1:
^
SyntaxError: invalid syntax
第19行是第一个if语句。
答案 0 :(得分:3)
你错过了这一行末尾的V
。
)