简体   繁体   中英

I don't understand this error message (Python)

I'm just beginning Python and I wrote this small program that's supposed to take user input and print a result. However, I don't understand the error that's occuring when I run it:

Code:

# The purpose of this program is to use the user's input (the price of their meal), and outputs a receipt telling them how much the meal costs with tax and an optional tip.

print("Thank you for coming! We hoped you enjoyed the meal. Please use our all new PythonBillPayer! A fast way to pay for your day!")

PriceOfMeal = float(input("Please enter the price of your meal"))
TipAmount = float(input("Please enter amount of tip you would like to give"))

def receiptCalculation(PriceOfMeal, TipAmount):
    NewPrice = (((((13/100)*PriceOfMeal)) + PriceOfMeal) + TipAmount)
    return NewPrice

print(receiptCalculation(PriceOfMeal))

Error Message:

builtins.TypeError: receiptCalculation() missing 1 required positional argument: 'TipAmount'

The method receiptCalculation need to Arguments: PriceOfMeal and TipAmount . receiptCalculation(PriceOfMeal) passes only one argument to the method, so it raises an Error.

receiptCalculation takes two arguments, yet on the line:

print(receiptCalculation(PriceOfMeal))

Only one argument is given. So the interpreter is telling you that you're missing exactly one argument in the call to your function.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM