Untitled

mail@pastecode.io avatar
unknown
plain_text
2 months ago
311 B
1
Indexable
Never
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)
Leave a Comment