First, random.shuffle()
shuffles the list into place. It does not return a shuffled list, so y = None
. That's why it does nothing when you type y
.
To call each function, you can go through x
and call each function as follows:
for function in x: function()
Finally, your functions actually throw a SyntaxError. If you want them to do nothing, add pass
at the end of them. pass
does nothing and is placed where python is expecting something.
So generally:
def func1(): pass def func2(): pass def func3(): pass x = [func1, func2, func3] random.shuffle(x) for function in x: function()
source share