really dont know how to go about this problem. I have done most of it however it isnt working out for me.
Can you paste the actual code and not a screenshot, because it makes it easier for others to test your code?
Also, please explain what are expecting your code to do vs. what it actually does.
To enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make easier to read.
See this post to find the backtick on your keyboard. The “preformatted text” tool in the editor (
</>) will also add backticks around text.
Note: Backticks are not single quotes.
bill = int(input("Bill: "))
cash = int(input("Cash: "))
change = cash - bill
if change >= 200:
two_hundred = (change // 200)
print(str("2 pounds: ", two_hundred))
change = change % 200
if change >= 100:
one_hundred = (change // 100)
print(str("1 pound: ", (one_hundred)))
change = change % 100
if change >= 50:
fifty = (change // 50)
print(str("50p: ", (fifty)))
change = change % 50
if change >= 20:
twenty = (change // 20)
print(str("20p: ", (twenty)))
change = change % 20
if change >= 5:
five = (change // 5)
print(str("5p: ", (five)))
change = change % 5
if change >= 2:
two = (change // 2)
print(str("2p: ", (two)))
change = change % 2
if change >= 1:
one = (change // 1)
print(str("1p: ", (one)))
change = change % 1
That is the code I have already created. there is a few errors inside there. What I need to do is a create a vending machine function where once given the bill e.g 700 and the cash given is 800 it would need to express the data as: two pounds: 4 one pounds: 0 50 pence: 0 20 pence: 0 10 pence: 0 5 pence: 0 2 pence: 0 1 pence : 0.
I am struggling. thank you for replying to me.
You should try and look at any error messages. I see there are red dots in your text editor and that is probably your editor telling you what’s wrong.
If you need any more hints, you should try by changing your integers to strings first before adding them to strings. Also, if you’re adding two strings together, you should use a + operator.
no overload variant of “str” matches argument types [Built.ins.str,built.ins.int]
this is the error message i have on all the red dots