Lesson 15: Hangman v1

posted Mar 29, 2019, 8:00 AM by Attila Lengyel
cl = ""
wl = " "
def draw(word, cl, wl):
a = ""
for c in word:
if c in cl:
a += c + " "
else:
a += "_ "
print(a)
if "_" not in a:
return "win"
elif len(wl) > 7:
return "lost"
else:
return "next"
word = input("Give me a word:")
status = draw(word, cl, wl)
while status == "next":
g = input("Guess a letter:")
if g in word and g not in cl:
cl += g
elif g not in wl:
wl += g
status = draw(word, cl, wl)
if status != "next":
print(status)

Comments