Invalid syntax error
Günther Dietrich
gd.usenet at spamfence.net
Sat Mar 10 08:17:06 EST 2012
In article
<46758542-1bd6-43fe-8e80-bcf14b7d88d8 at pi6g2000pbc.googlegroups.com>,
sl33k <ahsanbagwan at 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.
Best regards,
Günther
More information about the Python-list
mailing list