> In py2, map produces a list already. In any case, above is syntax error > without else clause. > > map(lambda x: x * -1 if x%2 else x, series) > > If you do not have a function already, a list comp is better. > > [(-1*k if k%2 else k) for k in range(2, N)] > > Change [] to () and you have a generator expression.
Thanks Terry [(-1*k if k%2 else k) for k in range(2, N)] is really short and I think pythonic being a list comprehension and works in py2 and py3. Sayth -- https://mail.python.org/mailman/listinfo/python-list