Reputation: 3
def secondscene():
second_options = ['1','2','3','4']
second_choice = ""
n = 25
while n > 0:
print('''The lion has''', n, '''health, how do you attack the lion:
1. Slash
2. Chop
3. Stab
4. Block''')
second_choice = input(str('Please enter a number between 1-3:'))
if second_choice == second_options[0]:
slash()
else:
print('please input one of the following listed numbers')
def slash():
import random
s = random.randint (1,10)
n = n - s
Can someone please explain to me how to use "n" in another function then use that function in the if statement. I'm trying to get the attacks all to do different damage. Thanks.
Upvotes: 0
Views: 27
Reputation: 939
That's a really basic question and you should start to see how to use POO in python which can be usefull for you.
def secondscene():
second_options = ['1','2','3','4']
second_choice = ""
n = 25
while n > 0:
print('''The lion has''', n, '''health, how do you attack the lion:
1. Slash
2. Chop
3. Stab
4. Block''')
second_choice = input(str('Please enter a number between 1-3:'))
if second_choice == second_options[0]:
n = slash(n)
else:
print('please input one of the following listed numbers')
def slash(n):
import random
s = random.randint (1,10)
n = n - s
return n
Upvotes: 1