Simple Way Of Referencing Last Element In Python


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
  1. print("Welcome To C#Corner....")  
  2. print('Referencing Last Elements :')  
  4. course=["c","c++","php","python","oracle"]  
  5. a=len(course)  
  6. print("%s" % course[a-1])  
  7. print("%s" % course[a-2])  

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.