mercredi 22 août 2018

error: choice() takes 2 positional arguments but 4 were given

def strategy(board):
import random
#t_1 =, t_2 and t_3 are ranges from 0 to a object named board
t_1 = [board[0] - i for i in range (0,(board[0] + 1))]
t_2 = [board[1] - i for i in range (0,(board[1] + 1))]
t_3 = [board[2] - i for i in range (0,(board[2] + 1))]

#randomly chooses a single number from each range
x = random.choice (t_1)
y = random.choice (t_2)
z = random.choice (t_3)

#randomly chooses one of those 3 randomly chosen numbers
q = random.choice (x,y,z)

As you can see the code randomly chooses a number from 3 different ranges and assigns each of them to a different variable. Once that is done, it randomly chooses one out of the 3 numbers chosen previously and assigns that a new variable. I keep getting the error mentioned in the title. I cant figure out whats wrong. Thanks for the help p.s. I am using python 3 with PyCharm




Aucun commentaire:

Enregistrer un commentaire