There is no need to keep switching between int
and str
. You can use str.format
to include the value in a string:
print "You have {0} coins left.".format(num_coins)
Instead of using a global
, make num_coins
an argument and return
it afterwards:
def coins(num_coins):
...
return num_coins
Now when you call coins
, do:
num_coins = coins(num_coins)
It is now much clearer what is happening.