Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import sys, random
- game = True
- #filename = sys.argv[0]
- filename = "words"
- # READING CONTENT
- content = open(filename, "r").readlines()
- for i in range(len(content)):
- content[i] = content[i].strip()
- # main loop
- while game:
- random.shuffle(content)
- word = list(content[0])
- shown_word = list("".join("_" for i in word))
- # guessing loop
- while True:
- while True:
- print(" ".join(shown_word))
- guess = input("> ")
- if len(guess) == 1:
- break
- if guess in word:
- for i in range(len(word)):
- shown_word[i] = word[i] if guess == word[i] else shown_word[i]
- if shown_word == word:
- break
- print("Guessed it!")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement