Do I have enough cash?
Jeepers, this recession is hurting my wallet. I better write a program to see if I can afford some items.
Start off with this code –
c = [1.99, 5.99, 4.50, 12.43, 99.99]
d = ["cookies", "cake", "chocolates", "posh chocs", "very posh chocs"]
a = 0
cash = 5.00
while a < len(c):
print "Item -",a ,"name", d[a], "costs",c[a]
a = a + 1
i = raw_input("Which item do you want to buy?")
Finish the code so it will say if you have enough money or not. Also it should say how much you have left if you managed to buy the item.
Sample output
Item - 0 name cookies costs 1.99
Item - 1 name cake costs 5.99
Item - 2 name chocolates costs 4.5
Item - 3 name posh chocs costs 12.43
Item - 4 name very posh chocs costs 99.99
Which item do you want to buy? 2
You can afford chocolates! You will have 0.5 left over
You need to log in or create an account to submit code!












