lundi 10 octobre 2016

Python 3: How to run functions with parameter in random order?

I knew how to run functions which doesn't have parameter. In this case, I want to run functions which has parameter in random order ?

It showed the result but not random and there is some error: Please help me correct the my code. Thank you :)

    import random
def hi(name):
    print('a ' + name)

def howold(old, name):
    print( name + 'is ' + old + "years old")

def howmuch(money):
    print(money + ' dollars')


functions = [hi('John'),howold('20', 'John'),howmuch('50')]
random.shuffle(functions)
for i in functions:
    i()




Aucun commentaire:

Enregistrer un commentaire