[Solved] Python random.choice same output


This is basically the same as

x = 42
print(x)
print(x)
print(x)

A variables value only changes when you assign it:

x = 42
print(x)
x = 45
print(x)

If you want a new random value, you need to call the function again:

l = [1, 2, 3, 4, 5]
x = random.choice(l)
print(x)
x = random.choice(l)
print(x)

6

solved Python random.choice same output