rand_arr=[0, ]
def rand_key_gen(arr):
for x in range(0, 25):
rand_arr[x] = random.choice(arr)
This is incomplete. But the problem here is that I might get the same value again. How do I circumvent this situation?
You'd use random.sample. It will select the required number of non-repeating elements from arr:
import random
rand_arr = [0]
def rand_key_gen(arr):
rand_arr[:] = random.sample(arr, 25)
There's no need for the loop, since you can modify rand_arr via slice assigment.
arrto appear once inrand_arr? (also for the record in Python they're called lists)