I am trying to pass a list of two integers created from one function so that I can manipulate them in succeeding functions.
def rollDie(number):
throw = []
for i in range(number):
roll = random.randint(1,6)
throw.append(roll)
return throw
So I have created another function game() that calls the rollDie() results:
def game(self,number):
if self.rollDie[0] != 1 or self.rollDie[1] != 1:
round_score = self.rollDie[0] + self.rollDie[2]
return round_score
But when I call the function game() it does not pull the two integers from rollDie():
print(game(2))
it returns error:
TypeError: game() missing 1 required positional argument: 'number'
I have researched here, here, here among other places inside stackoverflow. I am hoping someone can help. Many thanks for your patience.
gameaselfargument? Is it in a class? I think you should read the Python tutorial to get a grasp of the basics of functions in Python.game()is usingself.rollDie[2]. You probably meantself.rollDie[1].