Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Goes Right After by Alex_sashaemelyanov09
# Taken from mission Goes Right After (simplified)
def goes_after(word: str, first: str, second: str) -> bool:
if first == second:
return False
if first in word and second in word:
for num, char in enumerate(word):
if char == first and num != len(word) - 1:
if word[num + 1] == second:
return True
return False
elif char == second:
return False
return False
#print("Example:")
print(goes_after('almaz', 'm', 'a'))
# These "asserts" are used for self-checking
assert goes_after("world", "w", "o") == True
assert goes_after("world", "w", "r") == False
assert goes_after("world", "l", "o") == False
assert goes_after("panorama", "a", "n") == True
assert goes_after("list", "l", "o") == False
assert goes_after("", "l", "o") == False
assert goes_after("list", "l", "l") == False
assert goes_after("world", "d", "w") == False
assert goes_after("Almaz", "a", "l") == False
print("The mission is done! Click 'Check Solution' to earn rewards!")
Oct. 10, 2023
Comments: