please help me to assign a random value....down below almost at the end of this program.. I want to assign a random value in my hangman game.....help please i have made comment where i need help
import random
import time
wordlist = {'python', 'tomorrow', 'instagram', 'hacker', 'heaven', 'chopper', z, 'omnipresent', 'goggles', 'criminal', 'telescope', 'rainbow', 'qwerty', 'lamborghini', 'whirlpool'}
print "Start guessing..."
time.sleep(0.5)
word = (random.choice(wordlist)) ##### Don't know how to assign a random value from a list to a variable #####
guesses = ''
turns = 10
while turns > 0:
failed = 0
for char in word:
if char in guesses:
print char,
else:
print "_",
failed += 1
if failed == 0:
print "You won"
break
print
guess = raw_input("guess a character: ")
guesses += guess
if guess not in word:
turns -= 1
print "Wrong"
print "You have", + turns, 'more guesses'
if turns == 0:
print "You Loose"
Aucun commentaire:
Enregistrer un commentaire