Source Code:
(back to article)
# Define a list of fruits fruits = ['apple', 'banana', 'mango', 'orange'] # Try to find the index of 'grapes' in the list try: index = fruits.index('grapes') except ValueError: index = -1 # Print the index print(index)
Result:
Report an issue