blah
2010-07-07 00:38:33 UTC
#this is what I have
secretWord = "apple"
guess = "ppapp"
for i in guess:
a = codeWord.replace(i,"") #stores letters which have not been guessed
b = len(secretWord) - len(a) #takes the length of original word, minus length of 'a',
# giving number of correct guesses
print a
print b
print len(a)
#output:
ale
2
3
#end
What I wanted to do was replace matching inputted letters with "", which would essentially delete the letter. Than take the length of the secret word and subtract with the letters not matched (I used variable 'a' in the code). At the end, I get the number of correct letters inputted by the user.
I've been stuck for a while, I've tried re-writing it different ways, but can't get it. I need help! but it needs to be on the more basic side, I'm taking my first course in python