Can't get this Code to Run - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: Homework (https://python-forum.io/forum-9.html) +--- Thread: Can't get this Code to Run (/thread-7887.html) |
Can't get this Code to Run - dd3d - Jan-28-2018 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 RE: Can't get this Code to Run - j.crater - Jan-28-2018 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. RE: Can't get this Code to Run - dd3d - Jan-28-2018 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' RE: Can't get this Code to Run - j.crater - Jan-28-2018 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). |