Accessing random list entries in Python

Here some ways that you can access list elements at random, using the random module in Python:

ls = [1,2,3,4,5,6]

import random

# random choice
print("ls before: "+str(ls))
e = random.choice(ls)
print("e: "+str(e))
print("ls after: "+str(ls))

# random shuffle
random.shuffle(ls)
print("after shuffle: "+str(ls))

This outputs the following:

ls before: [1, 2, 3, 4, 5, 6]
e: 2
ls after: [1, 2, 3, 4, 5, 6]
after shuffle: [1, 5, 2, 6, 3, 4]