Question on for loop

Ricardo Aráoz ricaraoz at gmail.com
Mon Mar 4 08:21:42 EST 2013


El 04/03/13 09:18, newtopython escribió:
> Hi all,
>
> I'm super new to python, just fyi.
>
> In the piece of code below, secretWord is a string and lettersGuessed is a list. I'm trying to find out if ALL the characters of secretWord are included in lettersGuessed, even if there are additional values in the lettersGuessed list that aren't in secretWord.
>
> What this code is doing is only checking the first character of secretWord and then returning True or False. How do I get it to iterate through ALL of the characters of secretWord?
>
> for character in secretWord:
>          if character not in lettersGuessed:
>          return True
> return False
>
> Thanks!
>
> Ro

Indent the "return True" line so that it is inside the if clause.




More information about the Python-list mailing list