Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python3
- import random
- words = ['the', 'quick', 'brown', 'fox', 'jumps', 'over', 'the', 'lazy', 'dog']
- word = list(random.choice(words))
- guesses = ['_'] * len(word)
- lives = 3
- while lives > 0:
- if guesses == word:
- print("You win! Word was ā%sā" % ''.join(word))
- break
- print(guesses)
- print("Lives: %d" % lives)
- guess = input("Enter a character: ")
- if len(guess) != 1:
- print ("I said A (single) character!")
- continue
- guess_locations = [i for i, val in enumerate(word) if val == guess]
- if len(guess_locations) > 0:
- for g in guess_locations:
- guesses[g] = guess
- else:
- print('nope!')
- lives -= 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement