Hello I am creating a novice python game as practice and I have written this function that checks a variable (e.g. your strength level) and gives you a % chance to pass and increase the global variable.
import random
strength = 0
intelligence = 0
cunning = 0
def statCheck(x):
global strength
global intelligence
global cunning
winChance = random.randint(1,4) + x
if winChance >= 1:
x = x + 1
print(f"You have passed and gain one stat is it {x}")
return x
else:
print("You have failed")
I was expecting to pass strength/intelligence/cunning through it and have them increase for each time they pass the %chance but the value only increases the value of x.
import functions
strength = 0
intelligence = 0
cunning = 0
functions.statCheck(strength)
print(f"You have {strength} strength")
This gives me "You have passed and gain one stat is it 1" but also "You have 0 strength" How do I use a function to increase a variable in this way?