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


Groups > comp.lang.python > #41612

Re: Test a list

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!goblin2!goblin.stu.neva.ru!newsfeed.xs4all.nl!newsfeed4.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.037
X-Spam-Evidence '*H*': 0.93; '*S*': 0.00; 'else:': 0.03; 'skip:[ 20': 0.03; 'cc:addr:python-list': 0.10; 'googling': 0.16; 'loops': 0.16; 'syntax.': 0.16; 'wed,': 0.16; 'wrote:': 0.17; 'basically': 0.17; 'element': 0.17; '(or': 0.18; 'email addr:gmail.com&gt;': 0.20; 'cc:2**0': 0.23; 'script': 0.24; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; 'message-id:@mail.gmail.com': 0.27; 'subject:list': 0.28; 'sets.': 0.29; 'url:mailman': 0.29; 'skip:& 10': 0.29; "i'm": 0.29; 'url:python': 0.32; 'print': 0.32; 'url:listinfo': 0.32; 'equal': 0.33; 'received:google.com': 0.34; 'list': 0.35; 'clear': 0.35; 'pm,': 0.35; 'received:209.85.220': 0.35; 'received:209.85': 0.35; 'but': 0.36; 'url:org': 0.36; 'test': 0.36; 'thank': 0.36; 'received:209': 0.37; 'subject:: ': 0.38; 'url:mail': 0.40; 'your': 0.60; 'back': 0.62; 'more': 0.63; 'here': 0.65; 'legal': 0.65; '20,': 0.65; '2013': 0.84; 'subject:Test': 0.84; 'ana': 0.91; '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=7QtrUFMpfhLxZsV2R6UbRktwuyGU2+lNB/fl7yDPbts=; b=RGdvx0p/q19sbeop5q19ul9XKVwiy4lt93KljpA5HwSByhscFppx9a2872xBNE0gf6 bita5KfP0JpUIyj2mkzk9nBXzWa8Ijoa0aqZLSyT95iVPGp9fnA72BcNPhgavYOMFWK7 mVMg2pFwz54Ek5zZiwLKx5D5ibLyn60CChII/LIXUTRRK9rSuurz6zuzja/b/S9mK0I0 Arb8cxdy9vEHNA44EeJ2QF5Tk+gi9eIgffoBiNHd2n8rT9Uwp4sb0mTXGPSHagUTIeV5 tlwhfqt6b6Ke+svIA0qWf/vx7DuK2ZSCuUh/KFfNVIIZCNpWzQMSDA9+MQx28ctd3k2h Vwpg==
MIME-Version 1.0
X-Received by 10.220.153.143 with SMTP id k15mr9297507vcw.33.1363804003228; Wed, 20 Mar 2013 11:26:43 -0700 (PDT)
In-Reply-To <121be20a-c02a-4b0e-a86f-7c69597b9296@googlegroups.com>
References <121be20a-c02a-4b0e-a86f-7c69597b9296@googlegroups.com>
Date Wed, 20 Mar 2013 14:26:42 -0400
Subject Re: Test a list
From Joel Goldstick <joel.goldstick@gmail.com>
To Ana Dionísio <anadionisio257@gmail.com>
Content-Type multipart/alternative; boundary=f46d043d677127e7d404d85f5d53
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.3572.1363804006.2939.python-list@python.org> (permalink)
Lines 98
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1363804006 news.xs4all.nl 6892 [2001:888:2000:d::a6]:38009
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:41612

Show key headers only | View raw


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

On Wed, Mar 20, 2013 at 2:15 PM, Ana Dionísio <anadionisio257@gmail.com>wrote:

>
> t= [3,5,6,7,10,14,17,21]
>
> Basically I want to print Test 1 when i is equal to an element of the list
> "t" and print Test 2 when i is not equal:
>
>
> while i<=25:
>

You test i, but you don't set i to anything, or change it in your loop

you may want to try

  for i in range(25)  (or perhaps range(1,26)  i'm guessing.  Be more clear

>
>     if i==t[]:
>

This isn't legal syntax.  Try googling about for loops and sets.  Try again
and come back

>
>        print "Test1"
>
>     else:
>
>        print "Test2"
>
> What is missing here for this script work?
>
> Thank you all
> --
> 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

Test a list Ana Dionísio <anadionisio257@gmail.com> - 2013-03-20 11:15 -0700
  Re: Test a list timothy crosley <timothy.crosley@gmail.com> - 2013-03-20 11:24 -0700
  Re: Test a list Joel Goldstick <joel.goldstick@gmail.com> - 2013-03-20 14:26 -0400
  Re: Test a list Tim Chase <python.list@tim.thechases.com> - 2013-03-20 13:36 -0500
  Re: Test a list Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-03-20 18:40 +0000
  Re: Test a list John Gordon <gordon@panix.com> - 2013-03-20 20:39 +0000

csiph-web