Re: [Tutor] Beginner in need

2008-02-11 Thread Kent Johnson
Artur Sousa wrote:
> Sorry... forgot to add the code...
> 
> 2008/2/11, Artur Sousa <[EMAIL PROTECTED] >:
> 
> 
> 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
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Beginner in need

2008-02-11 Thread Artur Sousa
Sorry... forgot to add the code...

2008/2/11, Artur Sousa <[EMAIL PROTECTED]>:
>
>
> Hi. Just started on programming, as well on Python. I'm having a little
> problem:
>



 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:
   print a, 'equals', n, '*', a/n
   break
  else:
   print a, 'is a prime number'

each of the first spaces should be a "Tab".












-- 
Sorry for any inconvenience...
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor