Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random
- def showman(count):
- manparts = [" ", " o", " /|\\", " / \\", " "]
- structures = ["|____", "|", "|", "|", "|____"]
- for n, line in enumerate(structures):
- for ch in manparts[n]:
- if not count:
- break
- if ch != " ":
- count -= 1
- line += ch
- print(line)
- print("Your word: ", "".join(blanks), " Other letters tried: ", tried)
- words = ["these", "are", "the", "most", "wow", "basic", "english", "words", "check",
- "learn", "they", "happy", "fish", "common", "bag", "account", "for", "store",
- "speak", "read", "writing", "going", "ball", "smile", "run", "day", "night",
- "blunt", "with", "string", "until", "crowd", "empty", "tough", "fancy"]
- while True:
- answer = random.choice(words)
- anslist = list(answer)
- blanks = ["-"] * len(answer)
- tried = ""
- lives, livesleft = 6, 6
- while livesleft:
- showman(lives - livesleft)
- char = input("Enter a letter guess: ")
- if char not in anslist:
- livesleft -= 1
- tried += char
- else:
- while char in anslist:
- idx = anslist.index(char)
- blanks[idx] = char
- anslist[idx] = "."
- if "-" not in blanks:
- break
- showman(lives - livesleft)
- if "-" not in blanks:
- print("You win!")
- else:
- print("Sorry, you failed. The word was", answer)
- ch = input("\nPlay again? (Y/N): ")
- if not ch.lower().startswith("y"):
- break
- print("Goodbye")
Add Comment
Please, Sign In to add comment