Test a list

Joel Goldstick joel.goldstick at gmail.com
Wed Mar 20 14:26:42 EDT 2013


On Wed, Mar 20, 2013 at 2:15 PM, Ana Dionísio <anadionisio257 at 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20130320/967b8d9c/attachment.html>


More information about the Python-list mailing list