Jan-20-2018, 05:23 AM
I am learning python and want to create a more advanced tip calculator, however I tried testing it when I was half way done and kept on getting a syntax error with the variable "satispercent" between the 2 "else" functions keeps being highlighted. This was supposed to be so if anything but "Yes" was answered the person could reenter the tip. What is the error?
meal = 0.0 tip = 0.0 percent = str("percent") total = 0.0 satispercent = 0.0 satismeal = 0.0 satistip = 0.0 while meal != 0 or satisfied != str("yes"): meal = input("How much did your meal cost? Please enter amount as ##.##(ie 23.45): ") if str.isdigit(meal): meal = float(meal) while not str.isdigit(percent) or satispercent != str('yes'): percent = input("Great, how much would you like to tip? Enter your percent as a whole number (ie 20 will be 20 percent): ") if not str.isdigit(percent): print("Please enter your tip percent number in the format of a whole number!") else: percent = (float(percent) * meal * .01 satispercent = input("Okay, your tip will be " + percent + " dollars, is this okay? Simply enter 'Yes' with a capitol 'Y', everything else will be counted as 'No' and you will be able to re-enter your tip.") else: print("Please enter the number as instructed. ")