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


Groups > comp.lang.python > #40443

Re: Question on for loop

Path csiph.com!usenet.pasdenom.info!goblin2!goblin.stu.neva.ru!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <joel.goldstick@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; 'function,': 0.07; 'subject:Question': 0.07; 'welcome.': 0.07; 'get.': 0.09; 'iterate': 0.09; 'cc:addr:python-list': 0.10; 'guessing': 0.16; '\xc2\xa0\xc2\xa0\xc2\xa0\xc2\xa0\xc2\xa0': 0.16; 'mon,': 0.16; 'string': 0.17; 'wrote:': 0.17; 'email addr:gmail.com&gt;': 0.20; 'written': 0.20; 'all,': 0.21; 'trying': 0.21; 'cc:2**0': 0.23; "haven't": 0.23; 'script': 0.24; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; 'values': 0.26; 'thanks!': 0.26; 'am,': 0.27; 'checking': 0.27; 'question': 0.27; 'message-id:@mail.gmail.com': 0.27; 'lines': 0.28; 'all.': 0.28; 'run': 0.28; 'post': 0.28; 'piece': 0.29; 'running.': 0.29; 'url:mailman': 0.29; 'character': 0.29; 'included': 0.29; "i'm": 0.29; 'checked': 0.30; 'code': 0.31; 'url:python': 0.32; 'url:listinfo': 0.32; "aren't": 0.33; 'traceback': 0.33; 'received:google.com': 0.34; 'list': 0.35; 'false': 0.35; 'returning': 0.35; 'doing': 0.35; 'received:209.85.220': 0.35; "won't": 0.35; 'received:209.85': 0.35; 'there': 0.35; 'next': 0.35; 'list.': 0.35; 'url:org': 0.36; 'characters': 0.36; 'two': 0.37; 'received:209': 0.37; 'subject:: ': 0.38; 'mean': 0.38; 'some': 0.38; 'sure': 0.38; 'url:mail': 0.40; 'your': 0.60; 'below,': 0.60; 'first': 0.61; 'skip:\xc2 10': 0.62; 'provide': 0.62; 'here': 0.65; 'results': 0.65; 'subject': 0.66; '8bit%:100': 0.70; '2013': 0.84; 'joel': 0.91
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:cc:content-type; bh=4KPW9KJ2eDWmy9tr8FXMpJTS2VPAIydXpXw8kfu7yZo=; b=UsM5dgw2BLvTDAce44WOVRlTISk3hTOl12aHbOZslf0yTa8WH5bQReIc50NjFiTbpQ 6xIWCyC/DzG2tIM6yUrb0RBLKCntYcRqrgazThHOR7ZLuLZqXBqMu6pKMldfF3+uOw8Q 8KIRjJ4Z4+ayA1KZ/5Ahrh05gWfx7RUkojirs4Ltpf29pA4GpXVB1e9mBrRqCyCphHUl xwqON9OIEx5YLeFUhawFKj6hLTZEid7rCzWOfx1gG/CjSN5mVtuUnsS/yJ8riG4v2x7h 2xvAem6PpncY8VkDZdFIyih6yMqdOxaj1CmVO6WYuJKnm3mssAaSRSMsh/IXM/J0e8Ux 9kzg==
MIME-Version 1.0
X-Received by 10.58.220.66 with SMTP id pu2mr7720008vec.60.1362402299003; Mon, 04 Mar 2013 05:04:59 -0800 (PST)
In-Reply-To <d5f0feb6-533a-445b-a89a-8113c1668e9d@googlegroups.com>
References <d5f0feb6-533a-445b-a89a-8113c1668e9d@googlegroups.com>
Date Mon, 4 Mar 2013 08:04:58 -0500
Subject Re: Question on for loop
From Joel Goldstick <joel.goldstick@gmail.com>
To newtopython <roshen.sethna@gmail.com>
Content-Type multipart/alternative; boundary=047d7bd6adba12fbc704d7190113
Cc "python-list@python.org" <python-list@python.org>
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.2835.1362402307.2939.python-list@python.org> (permalink)
Lines 113
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1362402307 news.xs4all.nl 6898 [2001:888:2000:d::a6]:60533
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:40443

Show key headers only | View raw


[Multipart message — attachments visible in raw view] - view raw

On Mon, Mar 4, 2013 at 7:18 AM, newtopython <roshen.sethna@gmail.com> wrote:

> Hi all,
>
> I'm super new to python, just fyi.
>

Welcome.  Next time write a better subject line, and be sure the code you
post is actually the code you are running.  Provide the results you want
and what you get.  Provide the traceback if there is one

>
> 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:
>

I am guessing that the next two lines are actually indented in your script
so I am changing them here


            return True
>         return False
>
> The first time your if block is checked it will return True or False.
Since you haven't shown this code in a function, as written it won't run at
all.

Your question makes no sense.  What would it mean to look through each
character and return True or False?  What would make the result True?  All
matches, some matches?

> Thanks!
>
> Ro
> --
> http://mail.python.org/mailman/listinfo/python-list
>



-- 
Joel Goldstick
http://joelgoldstick.com

Back to comp.lang.python | Previous | NextPrevious in thread | Next 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