Making a hangman code (I'm a n00b, still in the tutorial stage)
Anyway, here's my (top-secret) code:
Anyways, I get down to line 6 and it tells me that global name z is not defined. I'm guessing I have to put the z thing in there, but I don't know how.
What should I do?
P.S. the code is still in development. That is why it is not finished.
Anyway, here's my (top-secret) code:
Code:
def guess():
choice=raw_input("Guess!(lowercase only please!)")
if len(choice)>1:
print "Don't cheat!"
guess()
elif guess in y:
b[z.find(choice)]=choice
print "Good Choice!"
print ''.join(b)
guess()
def main():
x=raw_input("Type a name")
y=x.lower().split(' ')
z=''.join(y)
print z
b=['_ ']*len(z)
print ''.join(b)
guess()
if __name__=='__main__':
main()
What should I do?
P.S. the code is still in development. That is why it is not finished.
Comment