Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Using index, docs in numpy style. solution in Clear category for Goes Right After by V.Shkaberda
def goes_after(word: str, first: str, second: str) -> bool:
"""
Check if one symbol goes only right after another. If any symbol
appears in a word more than once - use only the first one.
Parameters
----------
word : str
Word to check.
first : str
Symbol that should go first.
second : str
Symbol that should go after the first one.
Returns
-------
bool
Check result.
"""
try:
return word.index(first) +1 == word.index(second)
except ValueError:
return False
Oct. 5, 2021
Comments: