# # Name: CS 111 Course Staff # # lab4task4.py # # helper function def negate_if_even(val): """ input: a single integer val if val is even, the function returns -1 times val if val is odd, the function returns val without changing it """ if val % 2 == 0: return -1 * val else: return val def negate_evens_lc(vals): """ uses a list comprehension to return a version of the list vals in which all even numbers have been multiplied by -1. input: vals is a list of arbitrary of integers """ return [negate_if_even(x) for x in vals]