Toggle navigation
Log in
Sign Up
Log in
Sign Up
Appium
C
C#
C++
Docker
Go
Informatica
Java
JavaScript
Kafka
Numpy
Oracle
Pandas
PHP
Py Spark
Python
R
React Native
Scipy
SFTP
Tableau
Teradata
TGMC
UNIX
Introducing
Radical.sh
Forget Code launches a powerful code generator for building API's
Forget_Code.Models.CategoryViewModel
Add a new snippet
Basics
3
Conditional Statements
2
Dictionary
4
Input & Output
1
Lists
20
Sorting
1
Strings
1
Tuple
4
Choose Category
Get last element from a list in Python
Forget Code
Python
Get last element from a list
Array based access can retrieve the element from list, list[0] would return the first element from the list. Negative index can be used to access the list elements from end. -1 would retrieve last element of the list. -2 would return last but one.
investments = ['Mutual Fund', 'Equity', 'Stock'] print(investments[-1])
Output
Stock
Tags for Get last element from a list in Python
get last element from list
access list from end
print last element from list in python
DP_Lists
Contribute to Forget Code, help others.
Add snippet