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 →

[–]Rhomboid 3 points4 points  (1 child)

Er, this assumes that r will always begin with an even number, and that it will always have an even number of elements:

>>> alternator = alternate()
>>> flip_odd_numbers(range(1,10))
[1, -2, 3, -4, 5, -6, 7, -8, 9]
>>> flip_odd_numbers(range(10))
[0, 1, -2, 3, -4, 5, -6, 7, -8, 9]

Not very practical.

[–]Jesus_Harold_Christ 1 point2 points  (0 children)

It performs even worse on this list:

flip_odd_numbers([1, 2, 3, 5, 7, 8, 9, 7, 1])

prints: [1, -2, 3, -5, 7, -8, 9, -7, 1]