import random
n = int(input('Enter the number of Zombies: '))
r = float(input('Enter the range: '))
a = int(input('Enter the number of ammo: '))
def zombie_shootout(n,r,a):
n1 = n
for i in range(a):
if n == 0:
return "You shot all "+str(n1)+" zombies."
if r == 0:
return "You shot "+str(n1-n)+" zombies before being eaten: overwhelmed."
if a == 0:
return "You shot "+str(n1-n)+" zombies before being eaten: ran out of ammo."
x = random.randint(1,100)
if x <= 5: # Missed the shot
a -= 1
r -= 0.5
else: # Zombie Killed
a -= 1
n -= 1
r -= 0.5
return "You shot "+str(n1-n)+" zombies before being eaten: overwhelmed."
print(zombie_shootout(n,r,a))
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Python