Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
What is my error here?
#1
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. ")
Reply
#2
It looks like on line 18 there are two opening parentheses and only one closing parenthesis.
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020