from random import choice NUM_TURNS = 3 words = ['Hello', 'Today', 'Goodbye'] def game_play(): print words enter_word = raw_input("Guess which word the computer chose: ") random_word = choice(words) random_word_upper = random_word.upper() entered_word_upper = enter_word.upper() if entered_word_upper == random_word_upper: print "Good Job. It was " + random_word + "." return True else: print "You lose. It was " + random_word + ". " + "Try again." return False turns = 0 victory = False while turns < NUM_TURNS and not victory: print "You have %d turns left." % (NUM_TURNS - turns) turns += 1 victory = game_play() if not victory: print 'You have run out of turns!'