[1] Problem: https://py.checkio.org/en/mission/goes-after/
[2] My solution
python
접기def goes_after(word: str, first: str, second: str) -> bool: # your code here word_list = list(word) if (first not in word_list) or (second not in word_list): return False if first == second: return False first_index = word_list.index(first) word_list.pop(first_index) second_index = word_list.index(second) if first_index == second_index: return True else: return False
[3] Best Solutions
python
접기def goes_after(word: str, first: str, second: str) -> bool: try: return word.index(second)-word.index(first) == 1 except ValueError: return False
'프로그래밍 문제 > [Python] CheckIO' 카테고리의 다른 글
[Check-IO] Sum by Type (0) | 2021.12.12 |
---|---|
[Check-IO] Time converter (0) | 2021.12.10 |
[Check-IO] Absolute Sorting (0) | 2021.11.14 |
[Check-IO] Frequency Sorting (0) | 2021.04.18 |
[CheckIO] Median (0) | 2021.03.23 |
댓글