This is for a school assesment. I have done all the criteria needed and want to add more code relating to functions. Basically it is a 'game' where the program asks if you want to help defend a nearby village. if you say yes it will give you a list of troops you can pick to take. then it runs this code (keep in mind my current code works perfectly)
while enemy_score>=0:
if picked_troop == 1 or picked_troop == 2 or picked_troop == 3:
shoot = input()
if shoot == 'w':
enemy_score -= random.randint(1, 10)
print(enemy_score)
if enemy_score<0:
break
enemy_score has already been set to 50 and the 'if picked troop' line is to make sure that the shooting code needs to be run as shoot is greater than 0 at the start of the code (because shoot = 50).
I tried changing the code to..
def kill(enemy_score=None):
shoot = input()
if shoot == 'w':
enemy_score -= random.randint(1, 10)
print(enemy_score)
so i replaced everything from shoot = input() with kill,,,,, however when i do this the program takes the random number of 0 when the w key is pressed, and then returns to 50 again. so in the console it looks like this
w
46
w
47
w
46
w
48
how can i make this a continuous so it looks like
w
47
w
41
w
31
etc