Reputation: 23
I have a piece of code that broke the other day and I can't find the problem. I need to do something if I find a coincidence between a user input and the first value of any element of a list of lists. I had this code running in another computer, but somehow I can't make it run anymore:
if any(orderinput == x[0] for x in order):
orderinput
is the user input and order
is the list of lists. This worked once and should be working based on what I've read here on stackoverflow, but it throws a syntax error at the r
in for
.
I tried moving it between lines or adding spaces, but the error follows the r
.
I'm working in Python 2.2. I don't remember the version in the machine I made the code.
Upvotes: 2
Views: 1782
Reputation: 62928
Generator expressions are available since python 2.4. Try changing to a list comprehension:
if any([orderinput == x[0] for x in order]):
Python 2.2 is twelve years old. A lot of things were different.
Upvotes: 5