Light Mode
Dark Mode
Help

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: Jan. 24, 2022, 12:12 p.m.
Updated: Jan. 24, 2022, 5:05 p.m.
0
9
User avatar
shadai99