Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
index twice, once with start argument solution in Clear category for Second Index by TheRing
from contextlib import suppress
def second_index(text: str, symbol: str) -> [int, None]:
with suppress(ValueError):
return text.index(symbol, text.index(symbol) + 1)
return None
print("Example:")
print(second_index("sims", "s"))
assert second_index("sims", "s") == 3
assert second_index("find the river", "e") == 12
assert second_index("hi", " ") == None
assert second_index("hi mayor", " ") == None
assert second_index("hi mr Mayor", " ") == 5
print("The mission is done! Click 'Check Solution' to earn rewards!")
March 27, 2023