python newbie question

donmalla at yahoo.co.in donmalla at yahoo.co.in
Thu Jul 19 02:16:54 EDT 2001


Hi All,
I am a newbie to python. I am following the "Diving into Python 
tutorial".
However I am having a problem with the for loop
Here is the problem:

>>> vec = [2,4,6]
>>> [3*x for x in vec]
SyntaxError: invalid syntax

  In a  list called vec I assign values.when I ask it to print the 
list , it does print.
  >>> for x in vec:
   >>>    print x
  The o/p is 
  
  2 
  4
  6

However when I try to manipulate the list , using for loop like this :

[3*x for x in vec]

I get a syntax error "invalid syntax"

Please help me. I am using Python 1.5 on Windows 2000.

Cheers !!!!
-Ratnakar
------------------------------------------------------------

Ratnakar Malla,
 ECE Dept,
Louisiana State University,
Baton Rouge,
LA, 70802






More information about the Python-list mailing list