我必须编写一个程序,要求用户给他机票价格的年龄。每次用户插入文字值时,都会出现此错误:age = int(input(message))ValueError:int()以10为基的无效文字,并且我希望程序告诉用户插入一个数值,然后再次询问,有人可以帮我吗?ps。这是一个练习,必须使用while循环和条件语句的组合来编写:
message = "Welcome to the cinema,"
message += "\nplease enter you age: "
age = int(input(message))
while age:
if age < 3:
print(f"ok, for {age} years old people the ticket is free")
break
elif age in range(3, 13):
print(f"The ticket for {age} years old people is $10")
break
elif age > 12:
print(f"The ticket for {age} is $10")
break
else:
print("Please, enter a valid number!")
break
将此行放入while循环内
age = int(input(message))