| Total Complexity | 2 |
| Total Lines | 25 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | def goes_after(word: str, first: str, second: str) -> bool: |
||
| 2 | try: |
||
| 3 | first_index = word.index(first) |
||
| 4 | second_index = word.index(second) |
||
| 5 | except ValueError: |
||
| 6 | return False |
||
| 7 | return second_index == first_index + 1 |
||
| 8 | |||
| 9 | |||
| 10 | if __name__ == "__main__": |
||
| 11 | print("Example:") |
||
| 12 | print(goes_after("world", "w", "o")) |
||
| 13 | |||
| 14 | # These "asserts" are used for self-checking and not for an auto-testing |
||
| 15 | assert goes_after("world", "w", "o") == True |
||
| 16 | assert goes_after("world", "w", "r") == False |
||
| 17 | assert goes_after("world", "l", "o") == False |
||
| 18 | assert goes_after("panorama", "a", "n") == True |
||
| 19 | assert goes_after("list", "l", "o") == False |
||
| 20 | assert goes_after("", "l", "o") == False |
||
| 21 | assert goes_after("list", "l", "l") == False |
||
| 22 | assert goes_after("world", "d", "w") == False |
||
| 23 | assert goes_after("transport", "r", "t") == False |
||
| 24 | print("Coding complete? Click 'Check' to earn cool rewards!") |
||
| 25 |