I have tried to go about this and I can't get it to run. What am I doing wrong????
def price(pencil, book, discount, state_tax, shipping):
pencil = 5
book = 5
discount = .30
state_tax = .5
shipping = 7.50
price_1 = pencil + book + discount + state_tax +shipping
print = price_1
Next time when posting code, please use Python code tags, this time I added them. You can find
help here.
It is hard to guess what you wanted to achieve with this code, and much of it doesn't make sense. One way to make it run (if it was intended so at all) is like this:
def price(pencil, book, discount, state_tax, shipping):
pencil = 5
book = 5
discount = .30
state_tax = .5
shipping = 7.50
price_1 = pencil + book + discount + state_tax +shipping
print(price_1)
price(1,2,3,4,5)
Function
price() requires 5 arguments, but none of them are used in the function. Another variant of your code would be this:
def price(pencil, book, discount, state_tax, shipping):
price_1 = pencil + book + discount + state_tax + shipping
print(price_1)
price(5, 5, .30, .5, 7.5)
Though I doubt about the proper use of
discount and
state tax given the selected variable names.
Thanks for the reply.
I tried the simplified version. I get this error
TypeError: price_1() missing 4 required positional arguments: 'book', 'discount', 'state_tax', and 'shipping'
Error means you defined a function that expects 4 arguments (they are named in error message), but you called it with no arguments passed (empty braces).