Passed
Push — master ( e8c73d...5082ab )
by Ken M.
01:37
created

goes_right_after   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 21
dl 0
loc 25
rs 10
c 0
b 0
f 0
wmc 2

1 Function

Rating   Name   Duplication   Size   Complexity  
A goes_after() 0 7 2
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