Given that plist has been defined to be a list of 30 element
Given that plist has been defined to be a list of 30 elements, add 5 to its last element.
INSTRUCTOR NOTES: just requires a single line of code.
Use PYTHON, THANKS
Solution
some_list[-1] will retrieve the last element of the some_list without changing the list.
In fact, you can do much more with this syntax. The some_list[-n] syntax gets the nth-to-last element. So some_list[-1] gets the last element, some_list[-2] gets the second to last, etc.
So, adding 5 in last element of plist
plist[-1] = plist[-1] + 5
OR
plist[29] = plist[29]+5
