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

2013-11-23 Thread Steven D'Aprano
On Sat, Nov 23, 2013 at 08:57:54PM +0100, Rafael Knuth wrote: > I have only one question left. > Here's my original program again: > > for x in range(2, 10): > for y in range(2, x): > if x % y == 0: > print(x, "equals", y, "*", x//y) > break > else: >

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

2013-11-23 Thread Steven D'Aprano
On Sat, Nov 23, 2013 at 09:54:38PM +0100, Rafael Knuth wrote: > > 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. > > Oh, I didn't even know that such a thing exists :-) Cool! > Unfortunately, I only found Python REP

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

2013-11-23 Thread Alan Gauld
On 23/11/13 20:54, Rafael Knuth wrote: See? It has no output. By the way, the python REPL is your friend! Unfortunately, I only found Python REPLs for version 2.7.2 or lower. Is there a REPL for 3.3.0 ..? The REPL (read–eval–print loop) is the >>> prompt. You type stuff in and Python reads

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

2013-11-23 Thread Rafael Knuth
> 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. Oh, I didn't even know that such a thing exists :-) Cool! Unfortunately, I only found Python REPLs for version 2.7.2 or lower. Is there a REPL for 3.3.0 ..? Thanks, R

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

2013-11-23 Thread Don Jennings
On Nov 23, 2013, at 2:57 PM, Rafael Knuth wrote: > > 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 m

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

2013-11-23 Thread Rafael Knuth
@Peter @Steven @Don @Danny thank you *so much" for explaining the concept of a nested for loop! Your simplified example Steven made it very clear to me: for x in range(2, 7): print("outer loop, x =", x) for y in range(2, x): print("inner loop, x =", x, "y =", y) I have only one q