Hi...

I've this:

random_name = ['Mohamed', 'Ahmed','Aboubakr']
print "1: %s    2: %s    3: %s" % (random_name[1], random_name[0], random_name[2])

I want to print all the three names but in random way,

as: some time: Mohamed, Ahmed, Aboubaker

and some time: Mohamed, Aboubaker, Ahmed

and some time: Aboubaker, Ahmed, Mohamed

and some time ...

I used random and it doesn't work correctely !!

You are looking wrong place. Check itertools.permutations and random.choise

Edited 5 Years Ago by pyTony: n/a

You are looking for random.shuffle().
To see all method under random module use dir(random)
For help use help(random.shuffle)

>>> random_name = ['Mohamed', 'Ahmed','Aboubakr']
>>> random.shuffle(random_name)
>>> random_name
['Mohamed', 'Aboubakr', 'Ahmed']
>>> random.shuffle(random_name)
>>> random_name
['Ahmed', 'Mohamed', 'Aboubakr']
>>> random.shuffle(random_name)
>>> random_name
['Ahmed', 'Aboubakr', 'Mohamed']
>>>

Edited 5 Years Ago by snippsat: n/a

Comments
thanks

If you got your reply, it is your duty as OP (original poster) to close the thread as solved and give any reputation for excellent answer(s).

This question has already been answered. Start a new discussion instead.