On 12/01/2013 06:50 AM, Reuben wrote:
Hi,

How can we write a logic for detecting the number 2 in  range from 1 to 100

Do you mean:
        if 2 in numbers:
?

Also for a more general solution, think at the very nice function any(bools), in combination with a generator comprehension:

        numbers = [2,3,4,5,6,8]
        if any((n%2 == 1) for n in numbers):
            print("some is odd")
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to