I have just started to use python. The first program I made was a tip calculator and I have made three versions to rewrite and to add more. The next part of code I want to write is a loop that prompts a yes or no question. When 'yes' I want the program to loop back to the very start, when 'no' I want the program to exit, and when there is an invalid command I want the program to print('Invalid command.') and continue to wait for a 'yes' or 'no'. Here is the code:
print('Good evening sir, I am Tippos! Please, tell me the price of your meal and how much you would like to tip and I\'ll do the math for you!')
bill_amt = input('First sir, what was the price of your meal?(Please do not use signs such as "$"):')
tax = 1.13
x = float(bill_amt)
tip_amt = input('And how much would you like to tip? 10, 15, or maybe 20% Go on, any number sir!(Please do not use signs such as "%"):')
y = float(tip_amt)
tip_amt = x * (y / 100)
print('Your tip will cost you an extra' ,tip_amt, 'dollars.')
total_amt = (x + y) * tax
print('Your total cost will be' ,total_amt, 'dollars, sir.')
How do I add a loop that will restart the program at a certain input? Thanks! -Pottsy