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: 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>': 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: References: Date: Mon, 4 Mar 2013 08:04:58 -0500 Subject: Re: Question on for loop From: Joel Goldstick To: newtopython Content-Type: multipart/alternative; boundary=047d7bd6adba12fbc704d7190113 Cc: "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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: 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 --047d7bd6adba12fbc704d7190113 Content-Type: text/plain; charset=UTF-8 On Mon, Mar 4, 2013 at 7:18 AM, newtopython 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 --047d7bd6adba12fbc704d7190113 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable



On Mon, Mar 4, 2013 at 7:18 AM, newtopython <<= a href=3D"mailto:roshen.sethna@gmail.com" target=3D"_blank">roshen.sethna@g= mail.com> wrote:
Hi all,

I'm super new to python, just fyi.

= Welcome.=C2=A0 Next time write a better subject line, and be sure the code = you post is actually the code you are running.=C2=A0 Provide the results yo= u want and what you get.=C2=A0 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 in= cluded in lettersGuessed, even if there are additional values in the letter= sGuessed 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:
=C2=A0 =C2=A0 =C2=A0 =C2=A0 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


=C2=A0 =C2=A0 =C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return True
=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return False

The first time your if block is check= ed it will return True or False.=C2=A0 Since you haven't shown this cod= e in a function, as written it won't run at all.

Your= question makes no sense.=C2=A0 What would it mean to look through each cha= racter and return True or False?=C2=A0 What would make the result True?=C2= =A0 All matches, some matches?
Thanks!

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



--
--047d7bd6adba12fbc704d7190113--