[Tutor] Random module help

Alan Gauld alan.gauld at btinternet.com
Sat Oct 6 16:03:36 CEST 2007

"Norman Khine" <norman at khine.net> 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

More information about the Tutor mailing list