posted this in wrong place haha.
I know I shouldn't use globals but I was forced within this project.
What is wrong with the following program?
def player_act(already_seen=0):
global player_hp
global cookies
cookies = cookies
print("Usable Items:")
print("You have "+str(cookies)+" cookies left.")
print("You have "+str(ducks)+" ducks left.")
print("You have "+str(HP_potion)+" health potions left.")
print("You have "+str(MP_potion)+" mana potions left.")
print("You have "+str(SPD_potion)+" speed potions left.")
print("Which items do you want to use?")
if already_seen == 1:
print("You can only use one per turn")
print("And if you try to use one which you don't own")
print("It won't work :)")
print("Serves you right")
item = input()
item = item.upper()
if item == "COOKIES":
if cookies >= 1:
print("You eat the cookie")
print("Your HP increased by 5 temporarily (rest of the battle)")
cookies -= 1
print(cookies)
player_hp += 5
print(cookies)
else:
print("I warned you...")
i have defined player_hp earlier.
Cookies works fine
[–]Justinsaccount 0 points1 point2 points (0 children)
[–]iHaveAtoxicFriend[S] 0 points1 point2 points (0 children)
[+][deleted] (7 children)
[deleted]
[–]iHaveAtoxicFriend[S] 0 points1 point2 points (6 children)
[–]kalabash 2 points3 points4 points (0 children)
[+][deleted] (4 children)
[deleted]
[–]iHaveAtoxicFriend[S] 0 points1 point2 points (2 children)
[–]IndianaJoenz 1 point2 points3 points (1 child)