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


Groups > comp.lang.python > #41612

Re: Test a list

References <121be20a-c02a-4b0e-a86f-7c69597b9296@googlegroups.com>
Date 2013-03-20 14:26 -0400
Subject Re: Test a list
From Joel Goldstick <joel.goldstick@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.3572.1363804006.2939.python-list@python.org> (permalink)

Show all headers | 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