In Python 3, we are currently learning how to use the 'while' function. The following problem was posed to us in the chapter about 'while' functions, so I would assume I need to use the 'while' function for the problem. However, I feel like I could solve the problem using 'if' statements rather than a 'while' statement. Can someone please tell me if I'm wrong?
"A movie theater charges different ticket prices depending on a person's age. If a person is under the age of 3, the ticket is free; if they are between 3 and 12, the ticket is $10; and if they are over age 12, the ticket is $15. Write a loop in which you ask users their age, and then tell them the cost of their movie ticket."
My code:
age = input("How old are you? ")
age = int(age)
if age < 3:
print("Your ticket is free.")
elif age > 3 and age < 12:
print("Your ticket is $10")
elif age > 12:
print("Your ticket is $15")
Will this solve the problem? Thanks!