[Tutor] Help with simple coding

Alan Gauld alan.gauld at yahoo.co.uk
Fri Aug 14 16:38:09 EDT 2020


On 14/08/2020 16:33, Marshall Jones wrote:

> Spent hours on this, but seem to be getting further from getting it right.

There are a lot of things wrong here. Let's start at the top...

> money = int(input("how much money would you like to change into coins?"))
> coins = input("what coins do you want them in")

input() returns a string, so whatever you get back will be a string.

> pounds = (money // 1)
> fifty = (money // 0.5)
> twenties = (money // 0.2)
> tens = (money // 0.1)
> fives = (money // 0.02)
> twos = (money // 0.05)
> ones = (money // 0.001)

These values all store integers.

> if coins == pounds:

You are here comparing a string to an integer
eg.

if "pounds" == 42


-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos




More information about the Tutor mailing list