[Tutor] Two subsequent for loops in one function - I got it!

Don Jennings dfjennings at gmail.com
Sat Nov 23 21:26:52 CET 2013


On Nov 23, 2013, at 2:57 PM, Rafael Knuth wrote:

<snip>

> 
> The output of
> 
>    for y in range (2,2):
> 
> should be ... none - correct?

No, it's not none. It's an empty list; thus, python executes nothing inside the inner loop.

>>> range(2,2)
[]

>>> for y in range(2,2):
...     print 'yes, I made it to here'
... 
>>> 

See? It has no output. By the way, the python REPL is your friend! Use it often when you can't figure out what is happening.

Take care,
Don



More information about the Tutor mailing list