[Tutor] Beginner in need

Kent Johnson kent37 at tds.net
Mon Feb 11 20:11:36 CET 2008


Artur Sousa wrote:
> Sorry... forgot to add the code...
> 
> 2008/2/11, Artur Sousa <tucalipe at gmail.com <mailto:tucalipe at gmail.com>>:
> 
> 
>     Hi. Just started on programming, as well on Python. I'm having a
>     little problem:

It helps if you describe the problem. If you are getting an error 
message, copy/paste the entire error message, including the traceback, 
into your email.

>     What's the difference between:
> 
>  
> 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'
>  
> and
>  
> 
> for a in range(2, 10):
>   for n in range(2, a):
>   if a % n ==0:

The above line is missing an indent, it needs to be indented more than 
the 'for' line.

Kent


More information about the Tutor mailing list