Invalid syntax error

liuerfire Wang liuerfire at gmail.com
Sat Mar 10 14:00:22 CET 2012


在 2012年3月10日星期六UTC+8下午8时34分35秒,sl33k写道:
> 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

It is a indentation error. It should be like:

>>> while i<=num:
...     if num%i==0:
...         l.append(i)
...     i+=1
...
>>> print max(l)



More information about the Python-list mailing list