Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Built-in Functions Common to Most Data Structures
10. index() and ValueError


Good job! In the previous exercise, we mentioned that index() returns the index of the first occurrence of a given element. What if there is no such element at all?

In such a case, index() will throw a ValueError. To prevent this, we can use the following code:

requests_processed = [12, 18, 15, 23, 24, 8, 0, 18, 14, 13]
  print('Element not found')

This time, instead of an error, we'll simply get the message "Element not found".


Modify the solution from the previous exercise so that it returns an empty string if the input_letter is not found in the input_string.

Stuck? Here's a hint!

Use the try-except syntax shown in the exercise.