Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Python Programing Implement the function makeNeg() that takes a list of numbers

ID: 671754 • Letter: P

Question

Python Programing

Implement the function makeNeg() that takes a list of numbers and a number representing an index as a parameter and changes the list item at the specified index to be negative. If the number at the specified index is already negative, the function shouldn't change the list. The function should verify that the index is correct for the list. If the index isn't valid for the list, the function shouldn't change the list. The information below shows how you would call the function makeNeg() and what it would display for several different parameters, including cases where an invalid index is provided:

Python 3.4.1 Shell File Edit Shell Debug Options Windows Help >>> 1st 1 [1, 2, 3, 4] >> makeNeg(lsti, 2) >>> 1st1 >>> makeNeg(lsti, 2) >> lst1 >>>makeNeg(lsti, 5) That index is invalid. The list vas not changed >> lst1 >>makeNeg (lsti,-1) >>> lsti >>> 13e2 [-1, -2, -3, 0] >>> makeNeg(lst2, 0) >>1st2 t-1, -2,-3, 0] >>> makeNeg(lst2,-4) >> 1st2 [-1, 2, 3, 0] >>> makeNeg lst2, -5) That index is invalid. The list vas not changed >> lt2 Ln: 146 Col: 4

Explanation / Answer

Complete program:

sample output: