Learn python the hard way ex19 questions


Mark-4:pythontrial apple$ python3.6 ex19.py
We can just give the function numbers directly:
cheese: 20
crackers: 30
Traceback (most recent call last):
File “ex19.py”, line 12, in
cheese_and_crackers (f’{cheese}, {crackers}’)
TypeError: cheese_and_crackers() missing 1 required positional argument: ‘boxes_of_crackers’

I just just want to use “Input” feature in this exercise. obvious, I failed. I do hope somebody help me to straight things out, thanks.

Hi Mark,

The problem would appear to be that you are formatting your variables as strings when you pass them through the cheese_and_crackers function. After you get user input with your cheese and crackers variables, you’re going to pass the variables as parameters, like this: cheese_and_crackers(cheese, crackers). It’s just like passing in the numbers directly: cheese_and_crackers(1, 2).

Hope this helps!

1 Like

We can just give the function numbers directly:
You have 20 cheeses.
You have 30 crackers
Man thats enough for a party!
Get a blanket.

OR,we can use variables from our script:
we can even do the math inside too:
Traceback (most recent call last):
File “ex19.py”, line 18, in
cheese_and_crackers(10 + 2 , 6 + 5)
TypeError: ‘tuple’ object is not callableProcess finished with exit code 1. Please help me with this

It looks like cheese_and_crackers is not a function but a variable at that point.

Can you post your script?

Thanks @florian I got the correction it was a simple mistake where I wrote cheese_and_crackers = (amount_of_cheese , amount_of_crackers)
I was not supposed to enter the “=” sign and it worked perfectly

Yeah there is no assignment of cheese_and_crackers in your script.