Question: Write a functionincrement(L, x)to add x to each item of the list L! The function should change the list L in place. It should not
Write a functionincrement(L, x)to add x to each item of the list L!
The function should change the list L in place. It should not return anything.
Use the docstring """Changes list L in place by adding x to each item""".
Do not change the main program. Expected output:
|
Before: [1, 2, 3, 4, 5] After : [11, 12, 13, 14, 15] |
# Main program (do not change): nums = [1, 2, 3, 4, 5] print("Before:", nums) increment(nums, 10) print("After :", nums)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
