-3

There is in Python option to declare array like this?

arr = [x for x in vec where x < 2] - (Edit: sorry for the 'from'. my common mistake (the eclipse always repair me))

(or another statement without real loop)

  • possible duplicate of [if else in a list comprehension](http://stackoverflow.com/questions/4406389/if-else-in-a-list-comprehension) – Paul Seeb Jun 24 '14 at 19:50

1 Answers1

4

Use if instead:

arr = [x for x in vec if x < 2]

And note that it is a for loop, the from keyword does not exist.

julienc
  • 19,087
  • 17
  • 82
  • 82