Re: [Tutor] SEE THE QUESTION AT THE BOTTOM

2012-02-04 Thread Steven D'Aprano
Debashish Saha wrote: INPUT: *for n in range(2, 1000):* *for x in range(2, n):* *if n % x == 0:* Please don't add junk characters to your code. There is no need to add asterisks to each line, we can recognise Python code when we see it. Your code cannot run because of the ju

Re: [Tutor] SEE THE QUESTION AT THE BOTTOM

2012-02-03 Thread Steve Willoughby
On 03-Feb-12 21:38, Debashish Saha wrote: BUT I COULD NOT UNDERSTAND HOW THE COMMAND ELSE CAN WORK,THOUGH IT IS IN THE OUTSIDE OF THE FOR LOOP IN WHICH IF COMMAND LIES. The part that's confusing you is that it is not outside the for loop. It is PART of the for loop syntax. The loop construct

[Tutor] SEE THE QUESTION AT THE BOTTOM

2012-02-03 Thread Debashish Saha
INPUT: *for n in range(2, 1000):* *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'* OUTPUT: 2 is a prime number