The index() method returns the position of the first occurrence of a value. Given fruits = ["apple", "banana", "cherry", "banana"], fruits.index("banana") returns 1. If the value isn't found, it raises ValueError.
Check with in first to avoid this. You can limit the search range: fruits.index("banana", 2) starts searching from index , returning 3.
The count() method returns how many times a value appears: fruits.count("banana") returns 2, while fruits.count("grape") returns 0 (no error for missing values). Use index() when you need position, count() when you need frequency.