0
Some help if you will.
in my code, I am trying to call attributes[1] from the _attribs() so that I can add a random number to it in the psionics(). I need some expert assistance if you will. https://code.sololearn.com/cqZ9LreXdB7i/?ref=app
3 Answers
+ 1
dear James , you're in Python ,
indentation and spacing are the core of these programming.
you cause _attribs () you had space between attrib and () , I remake it into :
#coder: James Barrow
#Date: 08/10/17
#(updated: 08/11/17) created a tuple for the attribute names.
import random
#these are the variables
def psionic():
psi = random.randint(2, 100)
ISP = 0
if psi <= 15:
ISP =_attribs(attributes[1]) + random.randint(4, 24)
print ("Major Psionic I.S.P.:" +ISP)
else:
if psi <= 35:
ISP =_attribs(attributes[1]) + random.randint(2, 12)
print ("Minor Psionic I.S.P.:" +ISP)
else:
print("No psionics")
def _attribs():
''' This is a random attribute generator for Palladium Games RPGs. You can choose to role multiple times by entering 'y' in the input box'''
attributes = []
stats = ('I.Q.:', 'M.E.:', 'M.A.:', 'P.S.:', 'P.P.:', 'P.E.:', 'P.B.:', 'S.P.D.:')
for i in stats:
attributes = random.randint (3, 18)
if attributes < 16:
attributes = attributes + random.randint (1, 6)
print (i, attributes)
else:
print(i, attributes)
_attribs()
psionic()
choice = input("Would you like to roll again? (y or n)\n")
while choice == 'y':
_attribs()
psionic()
choice = input("Would you like to roll again? (y or n)\n")
+ 1
it runs well whenever you get rid spaces between _attrib and ()
0
it run great until you get a psionic character at which point it says attributes are undefined. the psionic() isn't able to get the 1st element from the attributes[1] list. how do i define attributes [] as global?