+ 1
To get last value in the list, one need to index from the back using negative value Example: nums = [2, 4, 6, 8, 10] nums[-1] = 10 The last value nums[:-1] = 2, 4, 6, 8 subtracts the last value nums[::-1] = 10, 8, 6, 4, 2 reverse the list from the last value
22nd Jul 2016, 8:04 AM
Benneth Yankey
Benneth Yankey - avatar