Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #40445
| Path | csiph.com!usenet.pasdenom.info!news.albasani.net!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <davea@davea.name> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.001 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'python,': 0.02; 'exception': 0.03; 'arguments': 0.07; 'false.': 0.07; 'subject:Question': 0.07; 'python': 0.09; 'iterate': 0.09; 'throw': 0.09; 'def': 0.10; 'encountered.': 0.16; 'returned,': 0.16; 'string': 0.17; 'wrote:': 0.17; 'written,': 0.17; 'code,': 0.18; 'all,': 0.21; 'trying': 0.21; 'header:In-Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; 'values': 0.26; 'am,': 0.27; 'checking': 0.27; 'possible,': 0.27; 'post': 0.28; 'behavior.': 0.29; 'complain': 0.29; 'indentation': 0.29; 'piece': 0.29; 'character': 0.29; 'included': 0.29; "i'm": 0.29; 'code': 0.31; "aren't": 0.33; 'like:': 0.33; 'true.': 0.33; 'to:addr:python- list': 0.33; 'that,': 0.34; 'wrong': 0.34; 'list': 0.35; 'false': 0.35; 'returning': 0.35; 'so,': 0.35; 'doing': 0.35; 'something': 0.35; 'there': 0.35; 'list.': 0.35; 'explain': 0.36; 'but': 0.36; 'characters': 0.36; 'subject:: ': 0.38; 'sure': 0.38; 'to:addr:python.org': 0.39; 'received:192': 0.39; 'received:192.168': 0.40; 'your': 0.60; 'below,': 0.60; 'first': 0.61; 'received:74.208': 0.71; 'retype': 0.91 |
| Date | Mon, 04 Mar 2013 08:36:45 -0500 |
| From | Dave Angel <davea@davea.name> |
| User-Agent | Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130106 Thunderbird/17.0.2 |
| 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 | 7bit |
| X-Provags-ID | V02:K0:u0yjvq0FSfpkt+lklAQZ3knTuVCczwOAOCJYIrH7UuV DYlfqC/CEnz8NUH8/tTi23AObyYQsCWHVghlTvxPAbcQ+2JsmE XQhUxtrhM/bKZ/Ptr/C1j4gNxu8f2h301nYJBPZMUas4iYTVA+ PF/K5QGuEt0J787GZcInf6OzkddmsIXgSwhK9zY3wQzgjN3KOG toKv01GiNyOszJ1vUuxiga0hdXyDHGmi3bZx9U9Wkm9qpZG0gF KjHdYneZpd6XneebBZvk1X++G6UPgCBh25ZkmkmY+dGQIYeZ87 AJjRs1Pcgl75gUfRzL8hr25gKuA82/Bqh38De5RYEp/WqyMdw= = |
| 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.2837.1362404218.2939.python-list@python.org> (permalink) |
| Lines | 38 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1362404218 news.xs4all.nl 6841 [2001:888:2000:d::a6]:41455 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:40445 |
Show key headers only | View raw
On 03/04/2013 07:18 AM, newtopython wrote:
> Hi all,
>
> I'm super new to python, just fyi.
Welcome to the Python list.
>
> 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
>
Please post a complete sample when possible, and make sure you
copy/paste it, not just retype it and hope. As written, it'll throw an
exception when return is encountered. But before that, it'll complain
about the indentation of the return True.
Perhaps you have something like:
def has_some_behavior(secretWord, lettersGuessed):
for character in secretWord:
if character not in lettersGuessed:
return True
return False
If so, please copy the whole thing from your code, and explain just how
you call it (what arguments are passed), what it returned, and what's
wrong with that behavior.
--
DaveA
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll 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