print("What is your age ?")
myAge = input()
if myAge <= "21" and myAge >= "18":
print("You are allowed to drive !")
elif myAge > "21":
print("You are too old to drive !")
elif myAge < "18":
print("You are too young to drive !")
Run Code Online (Sandbox Code Playgroud)
我想问一下上面的python代码是不是有什么问题?每当我输入一些小于 18 的数字时,都会出现“你太老了,不能开车!”的消息。虽然数字小于 18,但会出现。
使用这些代码行,我想创建一个程序,每当我输入任何小于 18 的数字时,都会显示一条消息“你太年轻了,不能开车!” elif在 python中使用语句出现。有人可以帮我做这件事吗?
python ×1