Re: [Tutor] Indexing in a series for a newbie

2006-01-19 Thread Danny Yoo
On Thu, 19 Jan 2006, Jon Moore wrote: > I need some help for a program I am writing as a newbie to Python. > > I have created a series: > > WORDS = ("python", "program", "code", "xylophone") > > and then assigned one of them randomly to the variable 'word': > > word = random.choice(WORDS) > > I

Re: [Tutor] Indexing in a series for a newbie

2006-01-19 Thread Todd Maynard
Another approach would be to change your data structure to include the words and hints together as tuples in the same tuple. ie... WORDS=( ("python","The python hint"),("program","The program hint"), ("code","The code hint") ) then you can do... word, hint = random.choice(WORDS) >>> WORDS=(

Re: [Tutor] Indexing in a series for a newbie

2006-01-19 Thread Wolfram Kraus
Jon Moore wrote: > Hello > > I need some help for a program I am writing as a newbie to Python. > > I have created a series: > > WORDS = ("python", "program", "code", "xylophone") > > and then assigned one of them randomly to the variable 'word': > > word = random.choice(WORDS) > > I know tha

Re: [Tutor] Indexing in a series for a newbie

2006-01-19 Thread Pujo Aji
Hello Jon,Why don't use randint so you can record the index and the value Example:    WORDS = ("python", "program", "code", "xylophone")    Indword = random.randint (0,len(WORDS)-1)    word = WORDS[Indword]    print Indword    print wordCheers,pujoOn 1/19/06, Jon Moore < [EMAIL PROTECTED]> wrote:He

[Tutor] Indexing in a series for a newbie

2006-01-19 Thread Jon Moore
HelloI need some help for a program I am writing as a newbie to Python.I have created a series:WORDS = ("python", "program", "code", "xylophone") and then assigned one of them randomly to the variable 'word':word = random.choice(WORDS)I know that if I do: print wordThe randomly chosen word will be