【发布时间】:2018-01-24 17:07:01
【问题描述】:
当我开发我的第一个代码时,我遇到了break 命令的问题,如果出现错误,我尝试使用该命令重新启动程序。
看一下代码也许你会更好理解。
Name = str(input("Please enter Your Name:"))
Age = input("Please enter your age: ")
if Age != int():
print ("Error! Check the age")
break
elif Age == int():
continue
Height = input("Please enter your height: ")
if Height != int():
print ("Error! Check the Height")
break
elif Height == int():
continue
if Age == int() and Age >= 18 and Height == int() and Height >= 148:
print("You're able to drive a car " + (Name) )
elif Age == int() and Age < 18 and Height == int() and Height > 148:
print("You're not able to drive a car " + (Name) )
elif Age and Height != int() :
print ("Error! , Age or Height are not numbers")
错误:
“C:\Users\Ghanim\Desktop\Coding\Documents\Projects\Python\Project1\Project1.py”,第 6 行 休息 ^ 语法错误:“中断”
外循环
【问题讨论】:
-
你的代码缩进好像坏了。
-
查看如何检查变量是否包含数字:stackoverflow.com/questions/3501382/…
标签: python python-3.x