On Mon, 20 Jul 2009, Richel Satumbaga wrote:
> I am just learning python then I encountered an certain point in terms of
> using the input function of python. the source code:
> eq = input("enter an equation:");
> print " the result is : ";
>
>
> the output seen in the command window:
>
> enter an equation:[m*x+b for m in (0,10,1),for x in (1,11,1), for b in
> (2,12,1)]
>
> Traceback (most recent call last):
> File "C:/Python26/try", line 1, in <module>
> eq = input("enter an equation:");
> File "<string>", line 1
> [m*x+b for m in (0,10,1),for x in (1,11,1), for b in (2,12,1)]
> ^
> SyntaxError: invalid syntax
[...]
It's the extra commas in your list comprehension.This should work:
[m*x+b for m in (0,10,1) for x in (1,11,1) for b in (2,12,1)]
HTH,
John
--
http://mail.python.org/mailman/listinfo/python-list