Re: [Tutor] Random module help

2007-10-07 Thread Norman Khine
Thank you, this is great. Alan Gauld wrote: Norman Khine [EMAIL PROTECTED] wrote q_keys.sort() a = [q[x] for x in q_keys] a = [random.choice(q[x]) for x in q_keys] So from this how do I choose a random element and produce a new dictionary like for example: See above. --

Re: [Tutor] Random module help

2007-10-06 Thread Alan Gauld
Norman Khine [EMAIL PROTECTED] wrote a = [q[x] for x in q_keys] a ['1q', '4q', '5q', '7q', '8q'] a ['1q', '4q', '5q', '7q', '8q'] This only returns the same questions, what am I doing wrong? How do I return a different set? I don't understand your problem. You are printing 'a'

Re: [Tutor] Random module help

2007-10-06 Thread Norman Khine
Alan Gauld wrote: Norman Khine [EMAIL PROTECTED] wrote a = [q[x] for x in q_keys] a ['1q', '4q', '5q', '7q', '8q'] a ['1q', '4q', '5q', '7q', '8q'] This only returns the same questions, what am I doing wrong? How do I return a different set? I don't understand your problem. You

Re: [Tutor] Random module help

2007-10-06 Thread Alan Gauld
Norman Khine [EMAIL PROTECTED] wrote But what I was wondering if possible in achieving is that my questions set (q) contains questions that are similar, i.e. they are written in different ways, so I wanted to get the random set of unique questions rather then have variations of the

Re: [Tutor] Random module help

2007-10-06 Thread Norman Khine
Hi Alan, Thanks for the suggestion, but I am not sure it is what I am after. From your dictionary, for example, I wanted to have a list as: what is your name? where do you live? then the next time I run the program I will get: who are you? what is your address? etc... rather then, what I

Re: [Tutor] Random module help

2007-10-06 Thread Alan Gauld
Norman Khine [EMAIL PROTECTED] wrote q_keys.sort() a = [q[x] for x in q_keys] a = [random.choice(q[x]) for x in q_keys] So from this how do I choose a random element and produce a new dictionary like for example: See above. -- Alan Gauld Author of the Learn to Program web site