Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.015 X-Spam-Evidence: '*H*': 0.97; '*S*': 0.00; 'python,': 0.02; 'character,': 0.07; 'false.': 0.07; 'subject:Question': 0.07; 'iterate': 0.09; 'cc:addr:python-list': 0.10; 'mon,': 0.16; 'string': 0.17; 'wrote:': 0.17; 'email addr:gmail.com>': 0.20; 'all,': 0.21; 'trying': 0.21; 'cc:2**0': 0.23; 'cc:no real name:2**0': 0.24; 'second': 0.24; 'linux': 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; 'ibm': 0.27; 'message-id:@mail.gmail.com': 0.27; 'piece': 0.29; 'sistemas': 0.29; 'url:mailman': 0.29; 'character': 0.29; 'included': 0.29; "i'm": 0.29; 'maybe': 0.29; 'code': 0.31; 'url:python': 0.32; 'url:listinfo': 0.32; "aren't": 0.33; 'like:': 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; 'but': 0.36; 'url:org': 0.36; 'characters': 0.36; 'received:209': 0.37; 'subject:: ': 0.38; 'fact': 0.38; 'some': 0.38; 'que': 0.38; 'url:mail': 0.40; 'below,': 0.60; 'first': 0.61; '8bit%:20': 0.62; '8bit%:31': 0.65; 'want,': 0.65; '8bit%:100': 0.70; '8bit%:98': 0.71; 'url:wordpress': 0.75; '2013': 0.84; 'skip:\xe6 20': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:mime-version:in-reply-to:references:from:date:message-id :subject:to:cc:content-type; bh=FpIX5EonOTpIvub2J3LLvPaW3TnV0IWb0epLKMYkwro=; b=BQv9nATQEVfcm1Y7zFB/dWla5TLvi4xasGUOxKCXNnaFXMpMpygI5fuh8mjzmNfppd w7NBYSm3ri2cT9VrhvXZR4tA4fYBQgDLzqakcZC1W/XhxmGeMowjrvzYHg5GG65y8R64 Hf+4Log0Iy7ls089VqDoxhDyXDCYbrZctlNall8A5sW1YXw/9IPjJywfA0U9aFlBTOPi TtJuXyKAtxvNzHTakJt57mJk5HFAFerT2+owfU4T4RR64A2/TcSqsMJc0y6P4WvIIdtJ bVa2s7E+zkOecEa4OGttvWEgM4lai2io+BP3Z1JwrKF/kIlZe9QSrBVF/+z88pL4ej3I 5Pfw== X-Received: by 10.49.59.105 with SMTP id y9mr34639687qeq.41.1362402000058; Mon, 04 Mar 2013 05:00:00 -0800 (PST) MIME-Version: 1.0 In-Reply-To: References: From: leo kirotawa Date: Mon, 4 Mar 2013 09:59:40 -0300 Subject: Re: Question on for loop To: newtopython Content-Type: multipart/alternative; boundary=047d7b6dc43c4142bd04d718ef51 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: 134 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1362402009 news.xs4all.nl 6856 [2001:888:2000:d::a6]:57729 X-Complaints-To: abuse@xs4all.nl Path: csiph.com!usenet.pasdenom.info!news.stben.net!border3.nntp.ams.giganews.com!border1.nntp.ams.giganews.com!nntp.giganews.com!xlned.com!feeder7.xlned.com!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Xref: csiph.com comp.lang.python:40442 --047d7b6dc43c4142bd04d718ef51 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable In fact this code is already doing what you want, but if the second character, by example, is not in secrectWord it'll jump out of the for and return. If you want that interact through the all characters and maybe count how many them are in the secrectWord, just take of the return there or do some list comprehension like: [ r for r in secrecWord if r in lettersGuessed] . []'s On Mon, Mar 4, 2013 at 9:18 AM, newtopython wrote= : > 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 secretWor= d > 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 > -- > http://mail.python.org/mailman/listinfo/python-list > --=20 Le=C3=B4nidas S. Barbosa (Kirotawa) Engenheiro de Software - IBM (LTC - Linux Technology Center) MsC Sistemas e Computa=C3=A7=C3=A3o Bacharel em Ci=C3=AAncias da Computa=C3=A7=C3=A3o. blog nerd: corecode.wordpress.com/ User linux : #480879 "Mais s=C3=A1bio =C3=A9 aquele que sabe que n=C3=A3o sabe" (S=C3=B3crates) "smile and wave" - =3DD + o/ (Penguins of Madagascar) =E6=97=A5=E6=9C=AC=E8=AA=9E=E3=81=AE=E5=AD=A6=E7=94=9F=E3=81=A7=E3=81=99=E3= =80=82 =E3=82=B3=E3=83=B3=E3=83=94=E3=83=A5=E3=83=BC=E3=82=BF=E3=82=B5=E3=82=A4=E3= =82=A8=E3=83=B3=E3=82=B9=E3=81=AE=E5=AD=A6=E4=BD=8D. --047d7b6dc43c4142bd04d718ef51 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable In fact this code is already doing what you want, but if the second charact= er, by example, is not in secrectWord it'll jump out of the for and ret= urn. If you want that interact through the all characters and=C2=A0 maybe c= ount how many them are in the secrectWord, just take of the return there or= do some list comprehension like: [ r for r in secrecWord if r in lettersGu= essed] .



[]'s

=C2=A0

On Mon= , Mar 4, 2013 at 9:18 AM, newtopython <roshen.sethna@gmail.com&g= t; wrote:
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 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:
=C2=A0 =C2=A0 =C2=A0 =C2=A0 return True
return False

Thanks!

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



--
Le=C3=B4n= idas S. Barbosa (Kirotawa)

Engenheiro de Software - IBM (LTC - Linux= Technology Center)
MsC Sistemas e Computa=C3=A7=C3=A3o
Bacha= rel em Ci=C3=AAncias da Computa=C3=A7=C3=A3o.

blog nerd: corecode.wordpress.com/

User linux=C2=A0: #480= 879

"Mais s=C3=A1bio =C3=A9 aquele que sabe que= n=C3=A3o sabe" (S=C3=B3crates)
"smile and wave" - =3DD += o/ (Penguins of Madagascar)

=E6=97=A5=E6=9C=AC=E8=AA=9E=E3=81=AE=E5=AD=A6=E7=94=9F=E3=81= =A7=E3=81=99=E3=80=82
=E3=82=B3=E3=83=B3=E3=83=94=E3=83=A5=E3=83=BC=E3= =82=BF=E3=82=B5=E3=82=A4=E3=82=A8=E3=83=B3=E3=82=B9=E3=81=AE=E5=AD=A6=E4=BD= =8D.
--047d7b6dc43c4142bd04d718ef51--