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:
>
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
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
> 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
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
@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
I agree with Peter Otten. I want to try restating what he said to try to
emphasize what I think is the key point.
One basic skill that you learn as a programmer is how to handle nesting.
One strategy is to give things names. This can have benefits:
1. The name itself might make the code ea
On Nov 22, 2013, at 9:24 AM, Rafael Knuth wrote:
> Hej there,
>
> newbie question: I struggle to understand what exactly those two
> subsequent for loops in the program below do (Python 3.3.0):
>
> for x in range(2, 10):
>for y in range(2, x):
>if x % y == 0:
>print(x, "
On Fri, Nov 22, 2013 at 03:24:31PM +0100, Rafael Knuth wrote:
> Hej there,
>
> newbie question: I struggle to understand what exactly those two
> subsequent for loops in the program below do (Python 3.3.0):
>
> for x in range(2, 10):
> for y in range(2, x):
> if x % y == 0:
>
Rafael Knuth wrote:
> Hej there,
>
> newbie question: I struggle to understand what exactly those two
> subsequent for loops in the program below do (Python 3.3.0):
>
> for x in range(2, 10):
> for y in range(2, x):
> if x % y == 0:
> print(x, "equals", y, "*", x//y)
>
Hej there,
newbie question: I struggle to understand what exactly those two
subsequent for loops in the program below do (Python 3.3.0):
for x in range(2, 10):
for y in range(2, x):
if x % y == 0:
print(x, "equals", y, "*", x//y)
break
else:
print(x
11 matches
Mail list logo