Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Selcting random words?

Status
Not open for further replies.

HiSiDeR

Technical User
Sep 15, 2002
2
AU
Hi all,

I am new to python and I need a little help. I want to select a random word from an Array. I have a Word_List and i would like to select a random word from it. It is for a hangman game and I can get it do everything but randomize
please help

Shane
 
Array, you mean a Python list object, don't you ?
Then you can do something like:


import random

# My list of words:
Word_List = ['poney','submarine','bird','chocolate']

# Get a random word:
print random.choice(Word_List)
 
Thankyou Sebsauvage

Your help was appreciated.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top