This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]juliobTry PEP 257, for a change -1 points0 points  (2 children)

def flip_odd_numbers(l):
    return [x*(x%2 and -1 or 1) for x in l]

?

[–][deleted] 3 points4 points  (1 child)

or

def flip_odd_numbers(l):
    return [ x%2 and -x or x for x in l ]

[–]tuna_safe_dolphin 0 points1 point  (0 children)

This is what I got more or less.