---
title: "How do I get the last element of a list in Python?"  
description: "How do I get the last element of a list in Python?"  
author: "Revati S Misra"  
published: 2023-04-27  
updated: 2023-05-01  
canonical: https://www.mindstick.com/forum/158050/how-do-i-get-the-last-element-of-a-list-in-python  
category: "python"  
tags: ["python", "python 2"]  
reading_time: 1 minute  

---

# How do I get the last element of a list in Python?

How do I get the last element of a list in [Python](https://www.mindstick.com/articles/75378/simple-yet-useful-tips-when-using-python)?

## Replies

### Reply by Aryan Kumar

In Python, you can get the last element of a list using negative indexing. Here's an example:

```python
my_list = [1, 2, 3, 4, 5]
last_element = my_list[-1]
print(last_element)  # Output: 5
```

In this example, **my_list[-1]** returns the last element of the list **my_list**, which is **5**. Negative indexing starts from the end of the list, with **-1** being the index of the last element, **-2** being the index of the second-last element, and so on.

\

### Reply by Krishnapriya Rajeev

Python supports *negative indexing,* where the index -1 denotes the last element, -2 denotes the second last element, and so on.

One can easily access the last element of a list as follows:

```plaintext
list = ['apple','banana','cherry','orange','papaya']
print(list[-1])			# printing the last element

# Output: papaya
```


---

Original Source: https://www.mindstick.com/forum/158050/how-do-i-get-the-last-element-of-a-list-in-python

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
