Skip to main content

Helps to find the last index of the element in list

Project description

listrindex

A lightweight Python utility that allows you to find the last index of an element in a list — something the built-in list.index() method does not support.


📌 Description

In Python, list.index(x) returns the first index of x in a list.
The listrindex class provides the method rindex(list, object) that returns the last index where the object appears.

This is especially useful when working with large datasets or when you want to find the last occurrence of repeated elements.


✅ Features

  • Returns the last index of a given value in a list.
  • Works with integers, strings, or any data type.
  • Raises ValueError if the element is not found, just like list.index().

🧪 Usage

from listrindex import listrindex

mylist = [5, 3, 7, 3, 9, 3]
value = 3

r = listrindex()
print(r.rindex(mylist, value))  # Output: 5 (last index of 3)

Project details


Release history Release notifications | RSS feed

This version

0.1

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

listrindex-0.1.tar.gz (1.8 kB view details)

Uploaded Source

File details

Details for the file listrindex-0.1.tar.gz.

File metadata

  • Download URL: listrindex-0.1.tar.gz
  • Upload date:
  • Size: 1.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.4

File hashes

Hashes for listrindex-0.1.tar.gz
Algorithm Hash digest
SHA256 1106000274a877dabd21f7b5f68bf7fbd4fbdd4d52dbab1b16016f3ef84738f9
MD5 4737fa8a2f4e5c98ec15bf7a436ca5ff
BLAKE2b-256 e443c723cb7cab1cd6761d17063250bd8cf8950096d292a26060804c336d09dc

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page