[Tutor] Don't understand error messages.
WM.
wferguson1 at socal.rr.com
Wed Apr 22 22:17:20 CEST 2009
Kent Johnson wrote:
> On Wed, Apr 22, 2009 at 2:57 PM, WM. <wferguson1 at socal.rr.com> wrote:
>
>> Using Windows XP, Python 2.6 & Al Sweigart's "Invent Your Own...", I keyed
>> in the Hangman Program. So far as I can tell it is totally proofed out.
>> Still, I get an error message which makes no sense to me.
>>
>
>
>> def DisplayBoard(HANGMAPIX, MissedLetters, CorrectLetters, SecretWord):
>> print HANGMANPIX[len(MissedLetters)]
>> print
>>
>> print 'MissedLetters:',
>> for Letter in MissedLetters:
>> print Letter,
>> print
>>
>> Blanks = '_' * len(SecretWord)
>>
>> for i in range(len(SecretWord)):
>> # 116 Replace Blanks with correctly guessed letters.
>> if SecrettWord[i] in CorrectLetters:
>> Blanks = Blanks[:i] + SecretWord[i] + Blanks[i+1:]
>> for Letters in Blanks:#Show SecretWord w 1 space between
>> letters.
>> print Letter,
>>
>
> The above line should be indented more than the previous line. I'm not
> sure if that is the cause of your error but give it a try and see.
>
> Kent
>
>
The indents were dis-arrayed e-mail, due to a long REM;
in the script the indents are as you suggest.
Blanks = '_' * len(SecretWord)
for i in range(len(SecretWord)):
# 116 Replace Blanks with correctly guessed letters.
if SecrettWord[i] in CorrectLetters:
Blanks = Blanks[:i] + SecretWord[i] + Blanks[i+1:]
for Letters in Blanks:
print Letter,
print
More information about the Tutor
mailing list