Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #40467

Re: Question on for loop

Date 2013-03-04 10:21 -0300
From Ricardo Aráoz <ricaraoz@gmail.com>
Subject Re: Question on for loop
References <d5f0feb6-533a-445b-a89a-8113c1668e9d@googlegroups.com>
Newsgroups comp.lang.python
Message-ID <mailman.2851.1362417534.2939.python-list@python.org> (permalink)

Show all headers | View raw


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.

Back to comp.lang.python | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

Question on for loop newtopython <roshen.sethna@gmail.com> - 2013-03-04 04:18 -0800
  Re: Question on for loop leo kirotawa <kirotawa@gmail.com> - 2013-03-04 09:59 -0300
  Re: Question on for loop Joel Goldstick <joel.goldstick@gmail.com> - 2013-03-04 08:04 -0500
  Re: Question on for loop Dave Angel <davea@davea.name> - 2013-03-04 08:36 -0500
  Re: Question on for loop Bryan Devaney <bryan.devaney@gmail.com> - 2013-03-04 06:34 -0800
    Re: Question on for loop Ian Kelly <ian.g.kelly@gmail.com> - 2013-03-04 09:37 -0700
      Re: Question on for loop Bryan Devaney <bryan.devaney@gmail.com> - 2013-03-05 03:12 -0800
      Re: Question on for loop Bryan Devaney <bryan.devaney@gmail.com> - 2013-03-05 03:12 -0800
  Re: Question on for loop Rick Johnson <rantingrickjohnson@gmail.com> - 2013-03-04 07:41 -0800
  Re: Question on for loop Ricardo Aráoz <ricaraoz@gmail.com> - 2013-03-04 10:21 -0300

csiph-web