Please explain me this piece of code:

choices = [
self.contents.pop(random.randint(0, len(self.contents) - 1))
for i in range(num_balls_drawn)
]

@SASUKE I think this is a random ball drawer, it is based on how many balls are available and then it proceeds to draw a random number/ball until there is none left.

1 Like

It creates an array “choices” by popping a random item from self.contents a num_balls_drawn number of times and placing it in said array.

1 Like

Thank you very much.