Iterator next() throw NameError

Viewed 27

I am trying to implement next(i for i,v in enumerate(l) if 12 in v) like in this post, but when I replace 12 with variable myvar, it throws error NameError: name 'myvar' is not defined. The code is:

myvar=12
next(i for i,v in enumerate(l) if myvar in v)

EDIT: I am using Eclipse+PyDev, it throws error, see img. enter image description here

How to solve this? Thank you.

0 Answers
Related