(May-09-2019, 08:03 PM)Gribouillis Wrote: The problem is that after running line 9, the code goes on with line 10. Why don't you simply replace line 9 with the break
statement?
Hi! So I actually have that already done but I'm trying to practice using a flag (following the practice problems in the book) so I'm attempting to revise my code so it adds a flag. Here is my code with a break:
prompt = "\nWhat is your age?" prompt += "\n(Enter 'quit' when you are finished.)" while True: age = input(prompt) if age == 'quit': break age = int(age) if age < 3: print("\nYour ticket is free!") elif age < 12: print("\nYour ticket is 10$!") else: print("\nYour ticket is 15$!")
(May-09-2019, 08:10 PM)buran Wrote: it's more common to skip the flagHi sorry! First, ty for your reply! I just posted below but I do already have a version of this with break. I'm just trying to practicing using a flag now. In addition, what do you mean by it's more common to skip a flag? Flags are not commonly used when coding? Is that a correct understanding of what you said? Thank you so much again!while True: age = input("\nWhat is your age?\n(Enter 'quit' when you are finished.)" ) if age == 'quit': break age = int(age) if age < 3: print("\nYour ticket is free!") elif age < 12: print("\nYour ticket is 10$!") else: print("\nYour ticket is 15$!")