Created
January 31, 2017 17:54
-
-
Save himan94/d692a31e203c678a827775588c9f1ae7 to your computer and use it in GitHub Desktop.
code to create a hangman game with 7 chances (
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
h = "namaste" | |
w = [] | |
s = len(h) | |
w.append(["O"] * s) | |
count = 0 | |
count1 = 0 | |
while (count < 7): | |
print w | |
if count1 == s : | |
print"you win" | |
break | |
d = raw_input("enter a letter:") | |
t = d | |
for i,j in enumerate(h): | |
if d == j: | |
print"hit" | |
print i | |
w[0][i] = t | |
count = count - 1 | |
count1 = count1 + 1 | |
count = count + 1 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
1 problem is that the code does not work properly if h(input) has spaces in between words ex- star wars
any help is really apreciated