Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First second index solution in Uncategorized category for Second Index by karol2202
def second_index(text: str, symbol: str) -> [int, None]:
"""
returns the second index of a symbol in a given text
"""
for i in text:
if symbol not in text:
return None
else:
indx = text.index(symbol)
text_list = list(text)
text_list[indx] = "0"
vin = "".join(text_list)
try:
return vin.index(symbol)
except:
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!")
Nov. 26, 2022
Comments: