logo
  • Python
  • Django
  • Tools
    • Email Extractor Tool Free Online
    • Calculate Text Read Time Online
    • HTML to Markdown Converter Online
    • Other Tools
  • About
  • Contact
  • Created with Sketch.
Created with Sketch.

Last modified: Jan 10, 2023 By Alexander Williams

getting the last item of list python

syntax

1
your_list[-1]

example

1
2
3
a_list=['elephant','dog','cat','zebra']print(a_list[-1])

output

1
zebra

Related Tutorials:

  • Understanding and Using Global Variables in Python
  • [Solved] ModuleNotFoundError: No module named 'numpy'
  • Estimating Reading Time of Text and Text File using Python
  • 3 Easy Methods for Capitalizing Last Letter in String in Python
  • How To Solve no module named datasets
  • Python Get Root and Sub Domain From URL
  • Python-pycountry | Understand How to Use pycountry
  • Python: Get First, Second, Last word in String

Recent Tutorials:

  • Debug and Test BeautifulSoup Scripts Efficiently
  • Extract Microdata & JSON-LD with BeautifulSoup
  • BeautifulSoup Asyncio Fast Web Scraping Guide
  • Scrape AJAX Content with BeautifulSoup
  • Avoid Getting Blocked While Scraping BeautifulSoup
  • BeautifulSoup Large-Scale Scraping Best Practices
  • Scrape JSON Data in HTML with BeautifulSoup
  • Extract HTML Tables to Pandas with BeautifulSoup
  • Facebook
  • Twitter
  • Youtube
  • PRIVACY POLICY
  • DMCA

Copyright PyTutorial Blog Co.