Re: compare items in list to x

2008-11-02 Thread Bruno Desthuilliers
Matt Herzog a écrit : I want a program that loops over a list of numbers (y) and tells me whether each number in the list is less than, greater than or equal to another number (x). In the below code, I can't get python to see that 2 is equal to 2. x = 2 def compare(): for y in ['12',

Re: compare items in list to x

2008-11-02 Thread asit
On Nov 2, 9:54 pm, "Pete Kirkham" <[EMAIL PROTECTED]> wrote: > 2 is not equal to '2' As the error is correctly marked, u have to convert '2' to 2 by using int() function so the write code is x = 2 def compare(): for y in ['12', '33', '2']: y=int(y) #string '2' is conver

Re: compare items in list to x

2008-11-02 Thread Pete Kirkham
2 is not equal to '2' -- http://mail.python.org/mailman/listinfo/python-list

compare items in list to x

2008-11-02 Thread Matt Herzog
I want a program that loops over a list of numbers (y) and tells me whether each number in the list is less than, greater than or equal to another number (x). In the below code, I can't get python to see that 2 is equal to 2. x = 2 def compare(): for y in ['12', '33', '2']: if x