I am writing a program for fun (hang man) and i get incorrrect syntax on this while loop
while wrong MAX_WRONG and so_far != word:
My whole program is this
import random
HANGMAN=( #this is the Hangman ascii art
"""
_________
| |
| 0
|
|
|
|
_________
| |
| 0
| |
|
|
|
_________
| |
| 0
| /|\\
|
|
|
_________
| |
| 0
| /|\\
| / \\
|
|
""")
MAX_WRONG=len(HANGMAN)-1
WORDS=("OVERUSED","CLAM","BACON","PUCK","TAFFY") #these are the words
word=random.choice(WORDS) #this is teh word that is going to be guessed
so_far="-"*len(word)#where the orrect letteres are viewd
wrong=0
used=[]# the letters incorrectly guessed
while wrong MAX_WRONG and so_far != word:
print HANGMAN[wrong]
print "YOu have used:\n",used
print "\nso far the word is:\n",so_far
guess=raw_input("\n\nEnter your guess:")
guess=guess.upper()
while guess in used:
print "You have already guessed the letter".guess
guess=raw_input("enter your guess")
guess=guess.upper()
used.append(guess)
if guess in word:
new=""
for i in range(len(word)):
if guess==word[i]:
new+=guess
else:
new+=so_far[i]
so_far=new
else:
print "INCORRECT"
wrong+=1
if wrong==MAX_WRONG:
print HANGMAN[wrong]
else:
print "YAAAAY"
print "the word was",word
All help is appreciated!
wrong MAX_WRONGdoes not make sense. You’ll need an operator between those two identifiers. You’re probably looking for<.