Tip Calculator Python Based on Service

Instead of the while loop you have in your code:

while service = amazing:

You should replace it with an

if .. :

elif ..:

else:

statement, and when testing for equality of a string value, you need to set it in quotes.

if service == "amazing":

Code below is what you (Raj) had on the other post linked at the top. I tried to edit your question, but it got rejected.


Code below is from Raj’s comment on his other post:

Heres what I have done for the questions

rbill = float(input("What is the total bill?"))
print("What was the level of service?")
service = input("Please choose amazing, okay, or horrible:")
while service = amazing:
    tip=(bill*0.20)
    total=(bill+tip)

print("The bill was $",bill)
print("The service was",service)
print("The tip is",tip)
print("The grand total with the tip is $",total)

– Raj Mar 8 at 6:22

Leave a Comment