Python – How to extract the last x elements from a list [duplicate]

it’s just as simple as:

my_list[-10:]

Additional Comment: (from the comments section)

If the initial list is less than 10 elements, then this solution will still work yielding the whole list. E.g. if my_list = [1,2,3], then my_list[-10:] is equal to [1,2,3]

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)