def second_index(text: str, symbol: str, ) -> [int, None]:
if not symbol in text and text.count(symbol) < 2:
return None
else:
return text.find(symbol, text.find(symbol) + 1)
I wrote the code above which works fine with all assertions except for the fourth (assert second_index("hi mayor", "") is None, "Fourth"), there I get -1 as a result.
Created at: 2022/01/24 12:12; Updated at: 2022/01/24 17:05