I'm having a problem understanding how this code works in lesson 4.4 on the
python tutorial. Can anyone explain it in easy-to-digest details? I kind of
know what most of the stuff means, but I can't comprehend how it all works in
unison. That, and I'm having a hard time understanding what break does.
for n in range(2, 10):
... for x in range(2, n):
... if n % x == 0:
... print(n, 'equals', x, '*', n//x)
... break
... else:
... # loop fell through without finding a factor
... print(n, 'is a prime number')
...
2 is a prime number
3 is a prime number
4 equals 2 * 2
5 is a prime number
6 equals 2 * 3
7 is a prime number
8 equals 2 * 4
9 equals 3 * 3Thanks for all your help,Greg
_______________________________________________
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor