Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Second Index by DavidVargas
def second_index(text: str, symbol: str) -> int | None:
# your code here
pos_result = None
first_position = 0
first_position = text.find(symbol)
for ind in range(first_position+1, len(text)):
if text[ind] == symbol:
pos_result = ind
break
return pos_result
print("Example:")
print(second_index("sims", "s"))
# These "asserts" are used for self-checking
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!")
Sept. 21, 2023