Session Ready
Exercise

enumerate()

Let's enumerate! Your task is, given a string, to define the function retrieve_character_indices() that creates a dictionary character_indices, where each key represents a unique character from the string and the corresponding value is a list containing the indices/positions of this letter in the string.

For example, passing the string 'ukulele' to the retrieve_character_indices() function should result in the following output: {'e': [4, 6], 'k': [1], 'l': [3, 5], 'u': [0, 2]}.

For this task, you are not allowed to use any string methods!

Instructions
100 XP
  • Define the for loop that iterates over the characters in the string and their indices.
  • Update the dictionary if the key already exists.
  • Update the dictionary if the key is absent.