Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Second Index by vhovhannisyan24
def second_index(text: str, symbol: str) -> [int, None]:
"""
returns the second index of a symbol in a given text
"""
# your code here
ans = []
if text.count(symbol) < 2:
return None
for ind, char in enumerate(text):
if char == symbol:
ans.append(ind)
return ans[1]
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!")
Dec. 30, 2022