我收到错误,我不太确定问题是什么。这是我的代码:
from random import *
gen = (randint(1,50))
#matt = (randint(1,28))
ex = (randint(1,40))
#lev = (randint(1,27))
book = raw_input("What book do you want to read from today? ").lower().strip('.')
x = "Your Random Chapter From " + book.upper() + " is Chapter "
#Genesis
if book == 'genesis':
print x + str(gen)
pass
elif book == 'gen':
print x + str(gen)
pass
#Exodus
elif book == "exodus":
print x + (str(ex)
pass
elif book == "ex"
print x + (str(ex))
pass
当前错误我在第21行"传递"
的语法问题C:\Users\\#####\Desktop\Python\UnfinishedProjects>RandomChapter.py
File "C:\Users\\#####\Desktop\Python\UnfinishedProjects\RandomChapter.py", line 21
pass
^
SyntaxError: invalid syntax
我几乎可以肯定还有更多的问题,但这就是现在给我带来问题的问题。如果你看到其他一些问题,请告诉我这个问题。谢谢!
答案 0 :(得分:0)
你错过了20号线末端的支架;第22行也缺少冒号。但是,您实际上并不需要任何if语句中的pass
。在任何情况下,通过将行10替换为:
#Genesis
if "gen" in book:
print x + str(gen)
#Exodus
elif "ex" in book:
print x + (str(ex)