Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Introduction
Built-in Functions Common to Most Data Structures
Summary
14. Question 2

Instruction

Nicely done! How about Question 2?

Exercise

Write a function named second_index(input_string, input_char) that returns the index of the second occurrence of input_char in input_string. If there is no such occurrence, return -1.

Stuck? Here's a hint!

First, you should find an index of first occurence, then slice the string:

input_string[first_occurrence+1:]

and find the index of the first occurrence of the letter in the sliced string. Then return the right result.

If input_char occurs only once in the string or doesn't appear at all, return -1.