在循环出现意外缩进和语法错误时尝试学习?(python)
下面的代码给了我意外的缩进,我已经尝试了很多变体,但是我一直遇到这些错误或语法错误在循环出现意外缩进和语法错误时尝试学习?(python),python,Python,下面的代码给了我意外的缩进,我已经尝试了很多变体,但是我一直遇到这些错误或语法错误 while True: try: a=int(input("Please enter a number to be counted down to: ")) b=(a-1) for count in range (100,b,-1): print (count) break except: print ("wohoo") while循环需要一个包含的代码块
while True:
try:
a=int(input("Please enter a number to be counted down to: "))
b=(a-1)
for count in range (100,b,-1):
print (count)
break
except:
print ("wohoo")
while循环需要一个包含的代码块:
while True:
try:
a = int(input("Please enter a number to be counted down to: "))
b = (a-1)
for count in range(100, b, -1):
print(count)
except:
print ("wohoo")
代码现在不起作用了。当在接受用户输入后运行时,它只是垃圾邮件“100”,这是因为您添加了中断。移除它以移除效果。它现在可以用了吗?Break将全部退出循环,因此只打印100个。它确实如此!非常感谢你的帮助。