while True :
Vehicle_Number_PLate = ('Please enter the vehicles number plate: ')
If len(Vehicle_Number_Plate)>7:
print ('The number plate is invalid, please try again')
Vehicle_Number_plate = FALSE
If len(Vehicle_Number_Plate)<7:
print ('The number plate is invalid, please try again')
请你能帮助我吗,我真的被困住了,我需要帮助。非常感谢
答案 0 :(得分:1)
评论中提到的If
应为if
,而FALSE
应为False
。要获得用户输入,请使用input('Please enter the vehicles number plate: ')
。您需要适当的缩进,并且您的变量与if
中的变量不匹配。我相信你正在寻找的东西是这样的:
valid=False
while not valid:
Vehicle_Number_Plate = input('Please enter the vehicles number plate: ')
if len(Vehicle_Number_Plate)!=7:
print ('The number plate is invalid, please try again')
else:
print ('The number plate is valid')
valid=True