我正在写一个程序,包括速度限制之类的while和if语句。我试着让它在输出结果后,它问我是否想用while循环重做程序
我听说如果我有一个太多的括号或一个开放的括号会发生这种情况。我所有的支架都很好
ques1 = int(input('What speed is the car travelling? '))
check = ques1
running = True
while running == True:
if 0 <= check <= 50:
print('You are clear.')
if 51 <= check <= 60:
print('10 demerit points')
if 61 <= check <= 70:
print('20 demerit points')
if 71 <= check <= 80:
print('30 demerit points')
if 81 <= check <= 90:
print('50 demerit points')
if 91 <= check <= 1000:
print("100 demerit points")
dasques = input('Do you want to try again? y/n '):
if dasques == ('n'):
running = False
预期输出:
Hoping to get :
50 demerit points
Do you want to try again? y/n
但我现在
"invalid syntax" with the colon behind: [ dasques = input('Do you want to try again? y/n '):]
以红色突出显示
请更改以下代码行
试试这个
相关问题 更多 >
编程相关推荐