Question: The following code segment is a short program that copies the elements from an integer list into another integer list and adds 1 to
The following code segment is a short program that copies the elements from an integer list into another integer list and adds 1 to each element. It then prints each element of both lists, the one without modifications, and the one that has 1 added to every element. There are 4 errors. Find and fix these errors. Hint: remember how to copy a list without pointing to the same list in memory. 1. values= [1,2,3,4,5] 2. newValues = values 3. for i in range (len (values) +1): values[i] +=1 4. print("Old Value at index {} is: {} ".format(i, newValues[i])) print("New Value at index () is: () ".format(i, newValues[i])) 5. 6.
Step by Step Solution
3.53 Rating (150 Votes )
There are 3 Steps involved in it
Step 1 Changes are done in above code 1 newValuesvaluescopy 2 for i in rangelenvalues 3 printOld Value at index is formati valuesi 4 printNew Value at ... View full answer
Get step-by-step solutions from verified subject matter experts
