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
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=(
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
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
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