Jul-03-2019, 03:03 AM
Hello everyone
I am new to Python and I am learning with a book I bought. In this book there are some do it yourself questions which are much more complicated than the examples. Now here is the code I wrote:
I am new to Python and I am learning with a book I bought. In this book there are some do it yourself questions which are much more complicated than the examples. Now here is the code I wrote:
age = input('Please enter your age. ') age = int(age) while age != 'quit' if age < 3: print('your ticket is free') elif 3<= age <= 12: print('you ticket is 10$') elif age > 12: print('your ticket is 15$')This code is supposed to ask the age and based on the age tell the price and there must be a loop ( which is why I used while ) but in the question it didn't ask me to specify how/when to stop the loop so the "while" statement doesn't look OK to me. question 1: How to write a loop for age and not to specify when to stop ( which means I don't want the user to be able to stop the loop. They just need to enter their age ) 2 question: when I run this code it asks for the age (prompt) and then it gives the ticket price statement but it doesn't stop for the second person to enter the age. It shows the :"your ticket is..." indefinitely. Sorry for long message.