2

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.

Uyghur Lives Matter
  • 18,820
  • 42
  • 108
  • 144

1 Answers1

5

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.

Pavel Anossov
  • 60,842
  • 14
  • 151
  • 124
  • Thank you very much, that was the problem. I think the other computer has python 2.4 now that you mention it. Thanks again. – Andres Castro Jul 04 '13 at 22:17