Introduction
In this blog, I will explain the simple way of how to reference the last element of a string, in Python. The code, shown below, will clearly mention the last word that I have given, and will display it in the Run module.
Software Requirement
Python 3.5.2
Simple Programming
- print("Welcome To C#Corner....")
- print('Referencing Last Elements :')
-
- course=["c","c++","php","python","oracle"]
- a=len(course)
- print("%s" % course[a-1])
- print("%s" % course[a-2])
Explanation
So, you can see that we have given a string in course. "oracle" is the last element of it. By using the simple way I referenced this last element. The word is now displayed in the Run module.
Output