[Tutor] seed & random !?
necati kaya
kaya4321@yahoo.com
Sun, 14 Oct 2001 02:27:21 -0700 (PDT)
Hi,
I am trying to generate different new_list randomly in
each step of the loop from original_list, but I can
not. As the example;
original_list=['1','2','3','4'] and my program produce
those new_lists randomly, but
['4', '2', '3', '1'] ==>
['1', '4', '2', '3'] Both are same
['4', '2', '3', '1'] ==>
['3', '2', '1', '4']
['2', '4', '3', '1']
I tried to use seed function, but it gave me all the
same results. Do you have any suggestion to have
different new_list which is generated from
original_list in every step.
Regards,
umit
Here is my code:
from random import Random
import random
original_list=['1','2','3','4']
for j in range(0, 5):
temp_list = original_list[:]
new_list=[]
for i in range(0, len(original_list)):
# random.seed()
#??????????????
choosen_item = random.choice(temp_list)
new_list.append(choosen_item)
temp_list.remove(choosen_item)
print new_list
print
__________________________________________________
Do You Yahoo!?
Make a great connection at Yahoo! Personals.
http://personals.yahoo.com