Untitled

 avatar
unknown
plain_text
a year ago
311 B
5
Indexable
def find_index(lst, item):
    try:
        index = lst.index(item)
        print(f"The index of '{item}' in the list is: {index}")
    except ValueError:
        print(f"'{item}' is not present in the list.")

# Example usage:
my_list = [10, 20, 30, 40, 50]
item_to_find = 30
find_index(my_list, item_to_find)
Editor is loading...
Leave a Comment