while age_price是一个死循环,因为 age_price恒定为真,要么不进入循环要么死循环,需要在内部break进行打破
while True:
n=input()
if n=='quit': #先判断是否结束
print('end')
break
n=int(n) #默认输入都是数字
if n<3:
price = 0
elif n<12:
price=10
else:
price=15
print(f'you need to pay {price} for tickets')
age_price="Tell me your age,and I'll tell you the price of the ticket:"
age_price=input(age_price)
age_price=int(age_price)
while age_price:
if age_price < 3:
price =0
break
elif age_price < 12:
price = 10
break
else:
price= 15
break
print(f"You need to pay ${price} for ticket")