+ 1
Can you pick a random function?
If i import the random module, make functions and put them into a list, can i make the random module pick one and successfully execute the function?
2 odpowiedzi
+ 2
import random
my_list = [max, min, divmod, pow]
x = random.randrange(len(my_list))
print(my_list[x](10, 2))
Possible outcomes:
10 # max
2 # min
(5, 0) # divmod
100 # pow
0
thank you!