Assuming that L is a list of values you want to choose from, then random. choice(L) will do the job.
randint() By using random. randint() we can add random numbers into a list.
Consider the following functions:
def a():
print "a"
def b():
print "b"
Is there a way to pick a function to run randomly? I tried using:
random.choice([a(),b()])
but it returns both functions, I just want it to return one function.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With