Python 如何修复“while”语句中的语法错误?
我正在为我的书制作书架的代码,我正在制作一个条件,条件是:当x变量小于y变量时,继续,否则,中断,但是python说在这行中,有一个语法错误,但是,我不理解错误在哪里 我尝试重新运行代码,验证标识空间,等等,但对我来说,没有什么错,而对于python来说,有一个语法错误Python 如何修复“while”语句中的语法错误?,python,python-3.x,loops,syntax-error,conditional,Python,Python 3.x,Loops,Syntax Error,Conditional,我正在为我的书制作书架的代码,我正在制作一个条件,条件是:当x变量小于y变量时,继续,否则,中断,但是python说在这行中,有一个语法错误,但是,我不理解错误在哪里 我尝试重新运行代码,验证标识空间,等等,但对我来说,没有什么错,而对于python来说,有一个语法错误 def lista() cadastrados = 0 livros = int(input("Quantos livros você deseja cadastrar?") while cadastr
def lista()
cadastrados = 0
livros = int(input("Quantos livros você deseja cadastrar?")
while cadastrados < livros:
print()
linha()
print()
print()
título = input("Put the title of your book: ")
autor = input("Put the writer of your book: ")
gênero = input("Put the gender of your book: ")
cadastrados += 1
if cadastrados >= livros:
break
我期待问题的循环,并将数字添加到cadastrados变量,如果数字达到极限,while循环将停止,但实际结果是突出显示while语句的无效语法您错过了一个闭合括号
livros = int(input("Quantos livros você deseja cadastrar?")
应该是
livros = int(input("Quantos livros você deseja cadastrar?"))
第2行缺少括号;