On Sat, Mar 10, 2012 at 6:17 AM, Günther Dietrich
<gd.use...@spamfence.net> wrote:
> In article
> <46758542-1bd6-43fe-8e80-bcf14b7d8...@pi6g2000pbc.googlegroups.com>,
>  sl33k <ahsanbag...@gmail.com> wrote:
>
>>I'm trying project euler problem 3 and I've hit the wall with this
>>error. What could be the problem here?
>>
>> l=[]
>>>>> num=600851475143
>>>>> i=1
>>>>> while i<=num:
>>...     if num%i==0:
>>...         l.append(i)
>>...     i+=1
>>... print max(l)
>>  File "<stdin>", line 5
>>    print max(l)
>>        ^
>>SyntaxError: invalid syntax
>
> You have to insert an empty line after the end of the while loop (before
> the print command), so that the interpreter can run and finish the loop
> before it is to print the result.

Note that this only applies to the interactive interpreter, to help it
identify when to terminate the block and pass on to the compiler.
When running a script, the extra blank lines are unnecessary, and
indentation alone identifies the blocks.
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to