Nested for loop problem
Don Low
m_tessier at sympatico.ca
Sat Nov 8 18:29:52 EST 2003
In article <3fad715f$0$58715$e4fe514c at news.xs4all.nl>, Irmen de Jong wrote:
> Don Low wrote:
>>>>>for x in range(2, 2):
>>
>> ... print x
>> ...
>>
>> Since x prints nothing, I guess x = NULL. If I try:
>
> That's your misunderstanding. That loop does *nothing*,
> it doesn't enter the loop body. When you're looping over
> an empty sequence, the loop body is never entered.
OK, so python knows not to even bother going through the loop if the
range is [].
>
> (also, NULL is meaningless in Python. I think you meant
> None, right?)
Yes, as in range(2, 2) yields nothing.
I have another question which I hope you can answer. If I do
2 % 2 in the python interpreter, the answer is 0, and yet 2 is a prime
number.
Thanks for your time,
Don
>
> --Irmen
>
--
Thanks,
Don
More information about the Python-list
mailing list