
Hangman
Hangman in python, not hard to add more letters.
apple = ["a","p","p","l","e"]
bean = ["b","e","a","n","s"]
carrot = ["c","a","r","r","o","t"]
dolphin = ["d","o","l","p","h","i","n"]
elephant = ["e","l","e","p","h","a","n","t"]
fish = ["f","i","s","h"]
gas = ["g","a","s"]
hot = ["h","o","t"]
igloo = ["i","g","l","o","o"]
jelly = ["j","e","l","l","y"]
kite = ["k","i","t","e"]
lion = ["l","i","o","n"]
moon = ["m", "o","o","n"]
nice = ["n","i","c","e"]
own = ["o","w","n"]
pig = ["p","i","g"]
quit = ["q","u","i","t"]
road = ["r","o","a","d"]
star = ["s","t","a","r"]
toad = ["t","o","a","d"]
use = ["u","s","e"]
vote = ["v","o","t","e"]
wind = ["w","i","n","d"]
xray = ["x","r","a","y"]
your = ["y","o","u","r"]
zebra = ["z","e","b","r","a"]
import random
correct = 0
Chances = 10
wrong = ""
ListWrong = []
Word = [apple, bean, carrot, dolphin, elephant, fish, gas, hot, igloo, jelly, kite, lion, moon, nice, own, pig, quit, road, star, toad, use, vote, wind, xray, your, zebra]
Chosen = Word[random.randint(0, 25)]
length = len(Chosen)
if length == 3:
Guesser = ["_","_","_"]
elif length == 4:
Guesser = ["_","_","_","_"]
elif length == 5:
Guesser = ["_","_","_","_","_"]
elif length == 6:
Guesser = ["_","_","_","_","_","_"]
elif length == 7:
Guesser = ["_","_","_","_","_","_","_"]
elif length == 8:
Guesser = ["_","_","_","_","_","_","_","_"]
print(Guesser)
print("You have", Chances, "chances.")
for control in range(0, 10, 1):
if correct == 0:
letter = str(input("Choose a letter:"))
Place = length
section = 0
while section != Place:
if letter == Chosen[section]:
Guesser[section] = Chosen[section]
section = section + 1
else:
wrong = letter
section = section + 1
print(Guesser)
Chances = Chances - 1
print("you have" , Chances, "chance(s) left.")
ListWrong.append(wrong)
print("The letters", ListWrong, "are incorrect or already used.")
if Chances == 0 and correct == 0:
print(Chosen, "was the word. You lose!")
if Guesser == Chosen and Chances > 0:
print("Good job! You guessed the word!")
print(Guesser)
correct = 1
section = Place
Chances = 0