I created a hangman game but it isn't working. The code is here:
import random
import sys
from string import whitespace
uy = 'jrekghqegherwgbeuihrweig'
choice = 'bhekvvvvvfaktgrwekubfhdbvbvdvbd'
z = 'bqhjrfqfbrqkqbg'
s = 'ksl'
s_space = 'bhks'
a4a = 'euwitrigqobehdbfbdjgks'
a5a = 'jbfbqwkgnkwqnjg sdn n nmsdafbdjnfbfhskbkjsahjdbhak'
a6a = 'qwertyuvdbgshnvdgshgfydss'
a7a = 'gsuhgbiusgdbgbsahghgasbghdibd'
a8a = 'ahwubshabuhsbhhhhhhhhhhhhhhajasfbhubfuibweyyyyyyyiuwwgyefwgyfehfddjskhjsghgfshgyeigiwyirgwey'
a9a = 'bhufooooooohvbfwgvhvnrnovgerhuthugoeioqqwertyuiopasdfghjklzxcvbnmfuwfviuhubvfhfhfvhbwehuvbhfbdihirfb'
a10a = 'ewhbgjbwqgbuebrhhgefwjhgbweuhbgfwbgi'
a11a = 'ehbgubwebghbwhbefibfweki'
a12a = 'igfwqwfiueubwfhbwdqiojiwf'
a13a = 'yregbuewiubhebwgiubewuigbgwehgbehgebfwgiueyrfhewighwiuebyhbfuhhhhhhhhhhhhhhhhhhhewfuhbhfieuttttttttttthgguuuuuuuuuuuuhhhhhhhhhhhhwhurweuhfurguyfgruiwuwerg hi!'
a14a = 'uebgqburbiguuuuuuuuuuuuuuuuuuubweiriubhiewwwwwwwwwwwwwwwhkwbhhhejhgekkkkki3333333333333ksssssssssssjxvnkgry'
a15a = 'eiwhoggggbvbiuvbwhiiiiiiiiiiiiiiiiiiiiiiiiiuhweiher'
a16a = 'fjdsohnnuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuufngnhudfnnnnnnnnnnnnnnnnnnnnngkjwkjre'
a17a = 'qnjwioeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeefyhreoyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyb3iuyrgbergyergyfegfyq653tr4@&^'
t = list(s)
hangman = """
+---+
| |
|
|
|
|
=========
"""
hangman1 = """
+---+
| |
O |
|
|
|
=========
"""
hangman2 = """
+---+
| |
O |
| |
|
|
=========
"""
hangman3 = """
+---+
| |
O |
|/ |
|
|
=========
"""
hangman4 = """
+---+
| |
O |
\|/ |
|
|
=========
"""
hangman5 = """
+---+
| |
O |
\|/ |
| |
|
=========
"""
hangman6 = """
+---+
| |
O |
\|/ |
| |
\ |
=========
"""
hangman7 = """
+---+
| |
O |
\|/ |
| |
/ \ |
=========
Game Over.
"""
animals = [ 'Swan']
space = ['astronomy', 'gas', 'nebula', 'planet', 'Earth', 'sun', 'space', 'star', 'Venus', 'Mars', 'Mercury', 'Pluto', 'Neptune', 'Uranus', 'ice', 'Jupiter', 'Saturn', 'asteroid', 'comet', 'Kepler', 'ISS', 'station', 'quasar', 'galaxy', 'Andromeda', 'moon', 'Phobios', 'Demios', 'orbit', 'gravity', 'matter']
food = ['pizza', 'bagel', 'donut', 'candy', 'cake', 'casserole', 'salmon', 'bacon', 'caviar', 'apple', 'bannana', 'orange', 'acai', 'pomegranete', 'pear', 'cheese', 'turkey', 'steak', 'Cabbage', 'Calorie', 'Carbohydrate', 'Casserole', 'Caterer', 'Celery', 'Chef', 'Chewy', 'Chicken', 'Chicory', 'Chipotle', 'Chips', 'Chocolate', 'Chocolatier', 'Choice', 'Chutney', 'Cocoa', 'Coffee', 'Condiment', 'mango', 'Crackers', 'Croutons', 'Crunchy', 'Cucumbers', 'potato', 'sandwich']
chemicals = ['alum', 'sodium', 'titin', 'Bichrome', 'Azurite', 'Borax', 'Calomel', 'Gypsum', 'graphite', 'hypo', 'lime', 'acetone', 'pollen', 'Aluminium', 'starch', 'soap', 'calcium', 'alchohol', 'seltzer', 'aspirin', 'bronze', 'chalk', 'diamond', 'marble', 'quartz', 'sand', 'silicon', 'vinegar', 'carbon', 'nitrogen', 'vapor', 'oxide', 'phosphorus', 'magnesium', 'acid', 'chemical', 'ackey']
print 'Welcome to hangman!'
import time
time.sleep(3)
print 'Pick a topic:'
print '1.Animals'
print '2.Space'
print '3.Food'
print '4.Chemicals'
topic = str(raw_input('Choose a topic(1/2/3/4):'))
if not topic.isalpha():
if topic == '1':
choice = animals
print 'animals'
elif topic == '2':
choice = space
print 'space'
elif topic == '3':
choice = food
print 'food'
elif topic == '4':
choice = chemicals
print 'chemicals'
else:
print 'Invalid Input'
topic = str(raw_input('Choose a topic(1/2/3/4):'))
elif topic != '1' or '2' or '3' or '4':
print 'Invalid Input'
topic = str(raw_input('Choose a topic(1/2/3/4):'))
if choice == animals:
word = random.choice(animals)
if choice == food:
word = random.choice(food)
if choice == space:
word = random.choice(space)
if choice == chemicals:
word = random.choice(chemicals)
word = word.lower()
length = len(word)
if length == 3:
s = '_ _ _'
a1a = word[0]
a2a = word[1]
a3a = word[2]
lis = [a1a, a2a, a3a]
if length == 4:
s = '_ _ _ _'
a1a = word[0]
a2a = word[1]
a3a = word[2]
a4a = word[3]
lis = [a1a, a2a, a3a, a4a]
if length == 5:
s = '_ _ _ _ _'
a1a = word[0]
a2a = word[1]
a3a = word[2]
a4a = word[3]
a5a = word[4]
lis = [a1a, a2a, a3a, a4a, a5a]
if length == 6:
s = '_ _ _ _ _ _'
a1a = word[0]
a2a = word[1]
a3a = word[2]
a4a = word[3]
a5a = word[4]
a6a = word[5]
lis = [a1a, a2a, a3a, a4a, a5a, a6a]
if length == 7:
s = '_ _ _ _ _ _ _'
a1a = word[0]
a2a = word[1]
a3a = word[2]
a4a = word[3]
a5a = word[4]
a6a = word[5]
a7a = word[6]
list = [a1a, a2a, a3a, a4a, a5a, a6a, a7a]
if length == 8:
s = '_ _ _ _ _ _ _ _'
a1a = word[0]
a2a = word[1]
a3a = word[2]
a4a = word[3]
a5a = word[4]
a6a = word[5]
a7a = word[6]
a8a = word[7]
lis = [a1a, a2a, a3a, a4a, a5a, a6a, a7a, a8a]
if length == 9:
s = '_ _ _ _ _ _ _ _ _'
a1a = word[0]
a2a = word[1]
a3a = word[2]
a4a = word[3]
a5a = word[4]
a6a = word[5]
a7a = word[6]
a8a = word[7]
a9a = word[8]
lis = [a1a, a2a, a3a, a4a, a5a, a6a, a7a, a8a, a9a]
if length == 10:
s = '_ _ _ _ _ _ _ _ _ _'
a1a = word[0]
a2a = word[1]
a3a = word[2]
a4a = word[3]
a5a = word[4]
a6a = word[5]
a7a = word[6]
a8a = word[7]
a9a = word[8]
a10a = word[9]
lis = [a1a, a2a, a3a, a4a, a5a, a6a, a7a, a8a, a9a, a10a]
if length == 11:
s = '_ _ _ _ _ _ _ _ _ _ _'
a1a = word[0]
a2a = word[1]
a3a = word[2]
a4a = word[3]
a5a = word[4]
a6a = word[5]
a7a = word[6]
a8a = word[7]
a9a= word[8]
a10a = word[9]
a11a = word[10]
lis = [a1a, a2a, a3a, a4a, a5a, a6a, a7a, a8a, a9a, a10a, a11a]
if length == 12:
s = '_ _ _ _ _ _ _ _ _ _ _ _'
a1a = word[0]
a2a = word[1]
a3a = word[2]
a4a = word[3]
a5a = word[4]
a6a = word[5]
a7a = word[6]
a8a = word[7]
a9a = word[8]
a10a = word[9]
a11a = word[10]
a12a = word[11]
lis = [a1a, a2a, a3a, a4a, a5a, a6a, a7a, a8a, a9a, a10a, a11a, a12a]
if length == 13:
s = '_ _ _ _ _ _ _ _ _ _ _ _ _'
a1a = word[0]
a2a = word[1]
a3a = word[2]
a4a = word[3]
a5a = word[4]
a6a = word[5]
a7a = word[6]
a8a = word[7]
a9a = word[8]
a10a = word[9]
a11a = word[10]
a12a = word[11]
a13a = word[12]
lis = [a1a, a2a, a3a, a4a, a5a, a6a, a7a, a8a, a9a, a10a, a11a, a12a, a13a]
if length == 14:
s = '_ _ _ _ _ _ _ _ _ _ _ _ _ _'
a1a = word[0]
a2a = word[1]
a3a = word[2]
a4a = word[3]
a5a = word[4]
a6a = word[5]
a7a = word[6]
a8a= word[7]
a9a= word[8]
a10a = word[9]
a11a = word[10]
a12a = word[11]
a13a = word[12]
a14a = word[13]
lis = [a1a, a2a, a3a, a4a, a5a, a6a, a7a, a8a, a9a, a10a, a11a, a12a, a13a, a14a]
if length == 15:
s = '_ _ _ _ _ _ _ _ _ _ _ _ _ _ _'
a1a = word[0]
a2a = word[1]
a3a = word[2]
a4a = word[3]
a5a = word[4]
a6a = word[5]
a7a = word[6]
a8a = word[7]
a9a = word[8]
a10a = word[9]
a11a = word[10]
a12a = word[11]
a13a = word[12]
a14a = word[13]
a15a = word[14]
lis = [a1a, a2a, a3a, a4a, a5a, a6a, a7a, a8a, a9a, a10a, a11a, a12a, a13a, a14a, a15a]
if length == 16:
s = '_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _'
a1a = word[0]
a2a = word[1]
a3a = word[2]
a4a = word[3]
a5a = word[4]
a6a = word[5]
a7a = word[6]
a8a = word[7]
a9a = word[8]
a10a = word[9]
a11a = word[10]
a12a = word[11]
a13a = word[12]
a14a = word[13]
a15a = word[14]
a16a = word[15]
lis = [a1a, a2a, a3a, a4a, a5a, a6a, a7a, a8a, a9a, a10a, a11a, a12a, a13a, a14a, a15a, a16a]
if length == 17:
s = '_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _'
a1a = word[0]
a2a = word[1]
a3a = word[2]
a4a = word[3]
a5a = word[4]
a6a = word[5]
a7a = word[6]
a8a = word[7]
a9a = word[8]
a10a = word[9]
a11a = word[10]
a12a = word[11]
a13a = word[12]
a14a = word[13]
a15a = word[14]
a16a = word[15]
a17a = word[16]
lis = [a1a, a2a, a3a, a4a, a5a, a6a, a7a, a8a, a9a, a10a, a11a, a12a, a13a, a14a, a15a, a16a, a17a]
s = s.replace(" ","")
print """
"""
print hangman
print s
while hangman != hangman7 or s_space != word:
guess = str(raw_input('Enter a letter:'))
if guess.isalpha():
if guess != a1a or a2a or a3a or a4a or a5a or a6a or a7a or a8a or a9a or a10a or a11a or a12a or a13a or a14a or a15a or a16a or a17a:
print 'Try again'
if hangman == hangman6:
hangman = hangman7
incorrect = guess
rong = []
rong.append(incorrect)
print hangman7
print s
print 'incorrect:'
print rong
sys.exit(" ")
elif hangman == hangman5:
hangman = hangman6
incorrect = guess
rong = []
rong.append(incorrect)
print hangman6
print s
print 'incorrect:'
print rong
elif hangman == hangman4:
hangman = hangman5
incorrect = guess
rong = []
rong.append(incorrect)
print hangman5
print s
print 'incorrect:'
print rong
elif hangman == hangman3:
hangman = hangman4
incorrect = guess
rong = []
rong.append(incorrect)
print hangman4
print s
print 'incorrect:'
print rong
elif hangman == hangman2:
hangman = hangman3
incorrect = guess
rong = []
rong.append(incorrect)
print hangman3
print s
print 'incorrect:'
print rong
elif hangman == hangman1:
hangman = hangman2
incorrect = guess
rong = []
rong.append(incorrect)
print hangman2
print s
print 'incorrect:'
print rong
elif hangman == hangman:
hangman = hangman1
incorrect = guess
rong = []
rong.append(incorrect)
print hangman1
print s
print 'incorrect:'
print rong
else:
gue = 'hi'
incorrect = guess
rong = []
rong.append(incorrect)
print hangman
print s
print 'incorrect:'
print rong
elif guess == a1a or a2a or a3a or a4a or a5a or a6a or a7a or a8a or a9a or a10a or a11a or a12a or a13a or a14a or a15a or a16a or a17a:
print hangman
print guess
s = s.replace(" ","")
if guess == a1a:
correct = a1a
t = list(s)
t[0] = guess
s = "".join(t)
elif guess == a2a:
correct = a2a
t = list(s)
t[1] = guess
s = "".join(t)
elif guess == a3a:
correct = a3a
t = list(s)
t[2] = guess
s = "".join(t)
elif guess == a4a:
correct = a4a
t = list(s)
t[3] = guess
s = "".join(t)
elif guess == a5a:
correct = a5a
t = list(s)
t[4] = guess
s = "".join(t)
elif guess == a6a:
correct = a6a
t = list(s)
t[5] = guess
s = "".join(t)
elif guess == a7a:
correct = a7a
t = list(s)
t[6] = guess
s = "".join(t)
elif guess == a8a:
correct = a8a
t = list(s)
t[7] = guess
s = "".join(t)
elif guess == a9a:
correct = a9a
t = list(s)
t[8] = guess
s = "".join(t)
elif guess == a10a:
correct = a10a
t = list(s)
t[9] = guess
s = "".join(t)
elif guess == a11a:
correct = a11a
t = list(s)
t[10] = guess
s = "".join(t)
elif guess == a12a:
correct = a12a
t = list(s)
t[11] = guess
s = "".join(t)
elif guess == a13a:
correct = a13a
t = list(s)
t[12] = guess
s = "".join(t)
elif guess == a14a:
correct = a14a
t = list(s)
t[13] = guess
s = "".join(t)
elif guess == a15a:
correct = a15a
t = list(s)
t[14] = guess
s = "".join(t)
elif guess == a16a:
correct = a16a
t = list(s)
t[15] = guess
s = "".join(t)
elif guess == a17a:
correct = a17a
t = list(s)
t[16] = guess
s = "".join(t)
print hangman
print s
if s == word:
print 'You Won!'
break
co = raw_input('Do you want to play again?(yes/no):')
if co == 'yes':
print """
"""
elif co == 'no':
sys.exit
else:
co = raw_input('Do you want to play again?(yes/no):')
elif gue == 'hi':
print hangman
print guess
s = s.replace(" ","")
if guess == a1a:
correct = a1a
t = list(s)
t[0] = guess
s = "".join(t)
elif guess == a2a:
correct = a2a
t = list(s)
t[1] = guess
s = "".join(t)
elif guess == a3a:
correct = a3a
t = list(s)
t[2] = guess
s = "".join(t)
elif guess == a4a:
correct = a4a
t = list(s)
t[3] = guess
s = "".join(t)
elif guess == a5a:
correct = a5a
t = list(s)
t[4] = guess
s = "".join(t)
elif guess == a6a:
correct = a6a
t = list(s)
t[5] = guess
s = "".join(t)
elif guess == a7a:
correct = a7a
t = list(s)
t[6] = guess
s = "".join(t)
elif guess == a8a:
correct = a8a
t = list(s)
t[7] = guess
s = "".join(t)
elif guess == a9a:
correct = a9a
t = list(s)
t[8] = guess
s = "".join(t)
elif guess == a10a:
correct = a10a
t = list(s)
t[9] = guess
s = "".join(t)
elif guess == a11a:
correct = a11a
t = list(s)
t[10] = guess
s = "".join(t)
elif guess == a12a:
correct = a12a
t = list(s)
t[11] = guess
s = "".join(t)
elif guess == a13a:
correct = a13a
t = list(s)
t[12] = guess
s = "".join(t)
elif guess == a14a:
correct = a14a
t = list(s)
t[13] = guess
s = "".join(t)
elif guess == a15a:
correct = a15a
t = list(s)
t[14] = guess
s = "".join(t)
elif guess == a16a:
correct = a16a
t = list(s)
t[15] = guess
s = "".join(t)
elif guess == a17a:
correct = a17a
t = list(s)
t[16] = guess
s = "".join(t)
print hangman
print s
if s == word:
print 'You Won!'
break
co = raw_input('Do you want to play again?(yes/no):')
if co == 'yes':
print """
"""
elif co == 'no':
sys.exit
else:
co = raw_input('Do you want to play again?(yes/no):')
My problem is that when I run it, the code, doesn't account for, or consider correct inputs - just counts them as wrong. I think the problem may be here:
while hangman != hangman7 or s_space != word:
guess = str(raw_input('Enter a letter:'))
if guess.isalpha():
if guess != a1a or a2a or a3a or a4a or a5a or a6a or a7a or a8a or a9a or a10a or a11a or a12a or a13a or a14a or a15a or a16a or a17a:
print 'Try again'
if hangman == hangman6:
hangman = hangman7
incorrect = guess
rong = []
rong.append(incorrect)
print hangman7
print s
print 'incorrect:'
print rong
sys.exit(" ")
elif hangman == hangman5:
hangman = hangman6
incorrect = guess
rong = []
rong.append(incorrect)
print hangman6
print s
print 'incorrect:'
print rong
elif hangman == hangman4:
hangman = hangman5
incorrect = guess
rong = []
rong.append(incorrect)
print hangman5
print s
print 'incorrect:'
print rong
elif hangman == hangman3:
hangman = hangman4
incorrect = guess
rong = []
rong.append(incorrect)
print hangman4
print s
print 'incorrect:'
print rong
elif hangman == hangman2:
hangman = hangman3
incorrect = guess
rong = []
rong.append(incorrect)
print hangman3
print s
print 'incorrect:'
print rong
elif hangman == hangman1:
hangman = hangman2
incorrect = guess
rong = []
rong.append(incorrect)
print hangman2
print s
print 'incorrect:'
print rong
elif hangman == hangman:
hangman = hangman1
incorrect = guess
rong = []
rong.append(incorrect)
print hangman1
print s
print 'incorrect:'
print rong
else:
gue = 'hi'
incorrect = guess
rong = []
rong.append(incorrect)
print hangman
print s
print 'incorrect:'
print rong
elif guess == a1a or a2a or a3a or a4a or a5a or a6a or a7a or a8a or a9a or a10a or a11a or a12a or a13a or a14a or a15a or a16a or a17a:
print hangman
print guess
s = s.replace(" ","")
if guess == a1a:
correct = a1a
t = list(s)
t[0] = guess
s = "".join(t)
elif guess == a2a:
correct = a2a
t = list(s)
t[1] = guess
s = "".join(t)
elif guess == a3a:
correct = a3a
t = list(s)
t[2] = guess
s = "".join(t)
elif guess == a4a:
correct = a4a
t = list(s)
t[3] = guess
s = "".join(t)
elif guess == a5a:
correct = a5a
t = list(s)
t[4] = guess
s = "".join(t)
elif guess == a6a:
correct = a6a
t = list(s)
t[5] = guess
s = "".join(t)
elif guess == a7a:
correct = a7a
t = list(s)
t[6] = guess
s = "".join(t)
elif guess == a8a:
correct = a8a
t = list(s)
t[7] = guess
s = "".join(t)
elif guess == a9a:
correct = a9a
t = list(s)
t[8] = guess
s = "".join(t)
elif guess == a10a:
correct = a10a
t = list(s)
t[9] = guess
s = "".join(t)
elif guess == a11a:
correct = a11a
t = list(s)
t[10] = guess
s = "".join(t)
elif guess == a12a:
correct = a12a
t = list(s)
t[11] = guess
s = "".join(t)
elif guess == a13a:
correct = a13a
t = list(s)
t[12] = guess
s = "".join(t)
elif guess == a14a:
correct = a14a
t = list(s)
t[13] = guess
s = "".join(t)
elif guess == a15a:
correct = a15a
t = list(s)
t[14] = guess
s = "".join(t)
elif guess == a16a:
correct = a16a
t = list(s)
t[15] = guess
s = "".join(t)
elif guess == a17a:
correct = a17a
t = list(s)
t[16] = guess
s = "".join(t)
print hangman
print s
if s == word:
print 'You Won!'
break
co = raw_input('Do you want to play again?(yes/no):')
if co == 'yes':
print """
"""
elif co == 'no':
sys.exit
else:
co = raw_input('Do you want to play again?(yes/no):')
So, help. Any ways to fix this?
P.S. the reason for animals[ ]
to have only 'Swans'
is for testing purposes.