How Do I Solve: [ValueError: invalid literal for int() with base 10:]
How Do I Solve: [ValueError: invalid literal for int() with base 10:]
command= " "
while True:
command = int(input("how old are you? "))
if command <= 12:
print("you're ticket is free.")
elif command <= 15:
print("you're ticket is .")
elif command > 15:
print("you're ticket is .")
elif command == "exit":
break
当我写 exit
它给出了 ValueError
,
ValueError: invalid literal for int() with base 10:'exit'
在尝试将命令转换为 int 之前,您应该检查命令是否已退出:
while True:
command = input("how old are you? ")
if command == "exit":
break
command = int(command)
if command <= 12:
print("you're ticket is free.")
elif command <= 15:
print("you're ticket is .")
elif command > 15:
print("you're ticket is .")
command= " "
while True:
command = int(input("how old are you? "))
if command <= 12:
print("you're ticket is free.")
elif command <= 15:
print("you're ticket is .")
elif command > 15:
print("you're ticket is .")
elif command == "exit":
break
当我写 exit
它给出了 ValueError
,
ValueError: invalid literal for int() with base 10:'exit'
在尝试将命令转换为 int 之前,您应该检查命令是否已退出:
while True:
command = input("how old are you? ")
if command == "exit":
break
command = int(command)
if command <= 12:
print("you're ticket is free.")
elif command <= 15:
print("you're ticket is .")
elif command > 15:
print("you're ticket is .")