Wrapping around a list in Python.

David Robinow drobinow at gmail.com
Mon Dec 16 07:41:57 EST 2013


On Mon, Dec 16, 2013 at 12:26 AM,  <shengjie.shengjie at live.com> wrote:
> The idea is to grab the last 4 elements of the array. However i have an array that contains a few hundred elements in it. And the values continues to .append over time. How would i be able to display the last 4 elements of the array under such a condition?

I assume you mean 'list' rather than 'array'.
If all you want to do is 'display' the last 4 elements:

big_list = [0,1,2,3,4,5,6,7,8,9]
last4 =  big_list[-4:]
print(last4)



More information about the Python-list mailing list