I'm working on writing two different shuffle functions.
The first shuffle function must take a list and return a new list with the elements shuffled into a random order.
This is what I have so far for the first shuffle function-
def shuf(List):
import random
newList=[]
for i in List:
i=random.randrange(len(List))
newList+=i
return newList
The second shuffle function takes a list as a parameter and shuffles the list in place.
I know how to do it with the built-in function but I'm not allowed to use it.
random.shuffle()is written in Python, so you could just read the source code. - Aya