Question: Python Use loop Write a function negate_odds (values) that takes a list of integers called values, and that modifies the list so that all of

Python
Use loop  Python Use loop Write a function negate_odds (values) that takes a

Write a function negate_odds (values) that takes a list of integers called values, and that modifies the list so that all of its odd- valued elements are replaced with their negated values, but all of its even-valued elements are left unchanged This function should not return a value Rather, it should should use a loop to modify the internals of the original list as needed For example, to modify element i of the list values, you should perform an assignment that looks like this values[i] = expression where expression is replaced with an appropriate expression for the new value of values [i. For reasons that we will discuss in lecture this week, any changes that the function makes to the internals of the list will still be there after the function returns. For example >>>valsi-[1, 2, 3, 4, 5, 6] >>>negate odds (vals1) >>vals1 >>> vals2 = [7, -3, 10, 8, -1] >>>negate odds (vals2) >>>vals2

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!