I’m attempting to program a small tip calculator for restaurants, I decided to add a confirm feature so that people could fiddle with the tip % before confirming, that way they wouldn’t have to reinput everything each time
but I keep getting an error on line 11 saying there are too many arguments.
Patron = float(input("How many of you ate together? "))
Cost = float(input("What was the total of the meal after tax? "))
Happy = False
while not (Happy):
Tip = float(input("What percentage tip do you plan on leaving? (just the number please) "))
C_Tip = Cost*(Tip/100) #lets add a way to confirm the value of the tip, looked up how the while command works
C_Total = C_Tip+Cost
Satisfied = float (input ("The tip will come out to be $", C_Tip, 'bringing the total to',C_Total,"is that ok?" )) #now realizing that I don't know what the code should do if they answer no
if Satisfied == ("Y") or Happy == ("yes") or Happy == ("Yes") or Happy == ("y"): #redundancies
Happy = True
else: #catching an error when I try to assign another value to "Happy" I'm assuming because it's identifying as true / false, just need to replace variable
print("Alright...")#forgot to float the input in line 11, lets see
#keeps saying it's expecting one argument but is recieving three
I’m expecting the code to loop back to input the percentage until the person is satisfied with the total cost
input ("The tip will come out to be $", C_Tip, 'bringing the total to',C_Total,"is that ok?" )
This is the problem. You can pass multiple arguments to print()
and it will print them all, but input()
doesn’t work like that.
Instead of using commas, you can use string concatenation +
like this:
input ("The tip will come out to be $" + str(C_Tip) + ' bringing the total to ' + str(C_Total) + " is that ok?")
Or, more conveniently, you can use an f-string:
input (f"The tip will come out to be ${C_Tip} bringing the total to {C_Total} is that ok?" )
Don’t make us guess what and where the exact error is. Please post the full error traceback message.
Please edit your question to provide the complete, exact error message, as well as a tag for the language you’re using for your code. Adding the proper tag will help get it in front of people who may be able to help, and the entire error message provides necessary information. You’ll find your experiences here will be much better if you spend some time taking the tour and reading the help center pages to learn how the site works and what the expectations are before you begin posting.
What programming language is this, Python? If so, please edit your question to add the respective tag