Skip to content

Instantly share code, notes, and snippets.

@suigetsu404
Forked from chrishorton/hangmanwordbank.py
Last active October 11, 2025 12:15
Show Gist options
  • Save suigetsu404/9deaf599638ff879ef67c06332e27bb3 to your computer and use it in GitHub Desktop.
Save suigetsu404/9deaf599638ff879ef67c06332e27bb3 to your computer and use it in GitHub Desktop.
Hangman ascii art and wordbank
# hangman game
# forked from chrishorton/hangmanwordbank.py for ASCII art
# wordbanks generated by ChatGPT
# all other code written from scratch
import random
import string
HANGMANPICS = [r'''
+---+
| |
|
|
|
|
=========''', r'''
+---+
| |
O |
|
|
|
=========''', r'''
+---+
| |
O |
| |
|
|
=========''', r'''
+---+
| |
O |
/| |
|
|
=========''', r'''
+---+
| |
O |
/|\ |
|
|
=========''', r'''
+---+
| |
O |
/|\ |
/ |
|
=========''', r'''
+---+
| |
O |
/|\ |
/ \ |
|
=========''']
# Categories and words
movies = [
"FROZEN", "AVATAR", "JAWS", "SHREK", "ROCKY", "UP", "CARS", "COCO", "MOANA",
"ALADDIN", "MULAN", "ENCANTO", "DUNE", "BATMAN", "BOLT", "TANGLED", "RANGO", "BRAVE"
]
video_games = [
"MARIO", "SONIC", "HALO", "DOOM", "PONG", "ZELDA", "TETRIS", "PORTAL", "PACMAN",
"MINECRAFT", "FORTNITE", "VALORANT", "ROBLOX", "SKYRIM", "FIFA", "AMONGUS", "TERRARIA", "OVERWATCH"
]
countries = [
"POLAND", "SPAIN", "JAPAN", "ITALY", "EGYPT", "CHILE", "INDIA", "NORWAY", "GREECE",
"CHINA", "CANADA", "FRANCE", "MEXICO", "SWEDEN", "BRAZIL", "TURKEY", "KOREA", "DENMARK"
]
animals = [
"CAT", "DOG", "LION", "BEAR", "FROG", "WOLF", "DUCK", "FISH", "CRAB",
"FOX", "DEER", "GOAT", "COW", "PIG", "RAT", "OWL", "BAT", "ANT"
]
food_and_drinks = [
"PIZZA", "BREAD", "MILK", "JUICE", "RICE", "CAKE", "SOUP", "APPLE", "CHEESE",
"PASTA", "BURGER", "STEAK", "WATER", "COFFEE", "TEA", "HONEY", "TACO", "LEMON"
]
music_artists = [
"ADELE", "DRAKE", "EMINEM", "SIA", "PINK", "QUEEN", "BEYONCE", "LIZZO", "USHER",
"RIHANNA", "TAYLOR", "SHAKIRA", "ELVIS", "ED", "KATY", "BILLIE", "BRUNO", "HARRY"
]
space_and_science = [
"STAR", "MOON", "SUN", "ATOM", "LIGHT", "ROCK", "DUST", "CLOUD", "SPACE",
"EARTH", "MARS", "VENUS", "COMET", "LASER", "ENERGY", "ORBIT", "METAL", "FORCE"
]
colors = [
"RED", "BLUE", "GREEN", "PINK", "BLACK", "WHITE", "ORANGE", "YELLOW", "BROWN",
"PURPLE", "GRAY", "CYAN", "BEIGE", "INDIGO", "VIOLET", "SILVER", "GOLD", "MAROON"
]
sports = [
"SOCCER", "TENNIS", "BOXING", "RUGBY", "CHESS", "SKIING", "HOCKEY", "RUNNING", "BASEBALL",
"CYCLING", "BASKETBALL", "SKATING", "SURFING", "ARCHERY", "GOLF", "ROWING", "VOLLEYBALL", "FENCING"
]
jobs = [
"CHEF", "NURSE", "PILOT", "BAKER", "FARMER", "ACTOR", "JUDGE", "SINGER", "DRIVER",
"DOCTOR", "TEACHER", "BUILDER", "WRITER", "ARTIST", "BARBER", "POLICE", "FIREMAN", "CLERK"
]
all_words = movies + video_games + countries + animals + food_and_drinks + music_artists + space_and_science + colors + sports + jobs
categories = {
1: "MOVIES",
2: "VIDEO GAMES",
3: "COUNTRIES",
4: "ANIMALS",
5: "FOOD AND DRINKS",
6: "MUSIC ARTISTS",
7: "SPACE AND SCIENCE",
8: "COLORS",
9: "SPORTS",
10: "JOBS",
11: "ALL WORDS"
}
choice = {
1: movies,
2: video_games,
3: countries,
4: animals,
5: food_and_drinks,
6: music_artists,
7: space_and_science,
8: colors,
9: sports,
10: jobs,
11: all_words
}
while True:
try:
strikes = 0
guesses = []
left = list(string.ascii_uppercase)
# choosing our category
print("CATEGORIES:")
for key, value in categories.items():
print(f"{key:4}: {value}")
category_choice = int(input("Choose your category (1-11): "))
if category_choice in choice.keys():
category_chosen = choice.get(category_choice)
else:
print("Invalid choice, please try again.")
continue
# randomly choosing word to be guessed
word = random.choice(category_chosen)
# beginning the game
print("Word you have to guess:")
print("_" * len(word))
while strikes != 7:
print(f"Guessed letters:", " ".join(guesses)) if guesses else None
print(f"Letters left to be guessed:", " ".join(left))
to_print = ""
guess = str(input("Guess a letter: ")).upper()
# validation
if guess in guesses:
print("You have already guessed that letter.")
continue
if len(guess) != 1:
print("Please enter a single letter.")
continue
guesses.append(guess)
left.remove(guess)
# printing the letters and hangmans in console
for letter in word:
if letter not in guesses:
to_print += "_"
else:
to_print += letter
print(to_print)
if guess not in word:
strikes += 1
print(HANGMANPICS[strikes - 1])
print()
if "_" not in to_print:
print("You won!")
break
if strikes == 7:
print(f"You lost! The word was: {word}")
# ending game
leave = input("Press ENTER to continue or q to quit.")
if leave.lower() == "q":
break
else:
continue
break
except ValueError:
print("Please enter a number.")
continue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment