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


Groups > comp.lang.python > #40467

Re: Question on for loop

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!ecngs!feeder2.ecngs.de!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <ricaraoz@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.005
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'python,': 0.02; 'false.': 0.07; 'subject:Question': 0.07; 'iterate': 0.09; 'clause.': 0.16; 'escribi\xf3:': 0.16; 'from:addr:ricaraoz': 0.16; 'from:name:ricardo ar\xe1oz': 0.16; 'indent': 0.16; 'string': 0.17; 'all,': 0.21; 'trying': 0.21; 'header:In-Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; 'values': 0.26; 'thanks!': 0.26; 'checking': 0.27; 'piece': 0.29; 'character': 0.29; 'included': 0.29; "i'm": 0.29; 'code': 0.31; "aren't": 0.33; 'to:addr:python- list': 0.33; 'received:google.com': 0.34; 'list': 0.35; 'false': 0.35; 'returning': 0.35; 'doing': 0.35; 'received:209.85': 0.35; 'there': 0.35; 'list.': 0.35; 'message-id:@gmail.com': 0.36; 'characters': 0.36; 'received:209': 0.37; 'subject:: ': 0.38; 'to:addr:python.org': 0.39; 'received:192': 0.39; 'received:192.168': 0.40; 'below,': 0.60; 'first': 0.61
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:message-id:date:from:user-agent:mime-version:to:subject :references:in-reply-to:content-type:content-transfer-encoding; bh=vHeiCb/UrYyPl267hzBvqPzRJgFXIBXV//yx4CDfoyM=; b=cUJBRGt+dXtyiG9ZHq/JL60Me9mL6MLVFBUvyCI/PXmR3CPrwfZm/8useKjLtq6zb1 NznAcMFh80FryVEm47+vrcLZWnnBxHrs2wuOjg9T6I0rEl4JbEW0oKU+SBdh1PiFiL35 4UDBOUgIXj5K3HuPMlMc0xYw20AoidFRkI9yWR3SyiCNR42iq8sLvPGPAIhiZsJrdQ1z 5v9xZkEHOhN5/URbGenHL2mXxCzjgwG1vlWEhQUiIBuUJAXQRal8s2oBz6OkK63eG7r5 UlRmYdYldLk9jnCR8sA+DP2tdT2QI1mDU5C0B1oQNAfOMUP2G5ZOqphgafUA1lGSkMaz nWVQ==
X-Received by 10.236.112.197 with SMTP id y45mr14093575yhg.121.1362403333053; Mon, 04 Mar 2013 05:22:13 -0800 (PST)
Date Mon, 04 Mar 2013 10:21:42 -0300
From Ricardo Aráoz <ricaraoz@gmail.com>
User-Agent Mozilla/5.0 (X11; Linux i686; rv:17.0) Gecko/20130221 Thunderbird/17.0.3
MIME-Version 1.0
To python-list@python.org
Subject Re: Question on for loop
References <d5f0feb6-533a-445b-a89a-8113c1668e9d@googlegroups.com>
In-Reply-To <d5f0feb6-533a-445b-a89a-8113c1668e9d@googlegroups.com>
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 8bit
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.2851.1362417534.2939.python-list@python.org> (permalink)
Lines 20
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1362417535 news.xs4all.nl 6935 [2001:888:2000:d::a6]:33279
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:40467

Show key headers only | 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