was wondering if I someone could lend a hand with the issue I am having with my python 3.4 code. I have found it hard to word my problem and searching the web for an answer has been difficult, so I thought it would be easier if I were to show the code and the issue to be resolved.
cola_cost = 2
surcharge = 0
def calc_takeaway(cost):
global surcharge
cost = cost * 1.05
surcharge = surcharge + (cost * 0.05)
cola_place = input("Do you want your cola to go? ")
if cola_place == "yes":
calc_takeaway(cola_cost)
print("$"cola_cost) ## cola cost should be $2.10 but instead prints out $2
print("$"surcharge)
Basically, my cola_cost
will not change its global value after being passed into the calc_takeaway
function. Sorry if this is too basic I would kist like to get this issue solved. Thank you.
EDIT: I'd also like to mention that I would like to use the function on different cost variables (i.e fanta_cost, water_cost...) as well.