Test Setup Failed
Push — master ( a88ac6...de2ece )
by Ken M.
01:09
created

left_join()   A

Complexity

Conditions 2

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
1
def left_join(phrases):
2
    # Join strings and replace "right" to "left"
3
    text = ','.join(phrases)
4
    while text.find('right') != -1:
5
        text = text.replace('right', 'left')
6
    return text
7
8
9
if __name__ == '__main__':  # pragma: no cover
10
    # These "asserts" using only for self-checking and not necessary for
11
    # auto-testing
12
    assert left_join(("left", "right",
13
                      "left", "stop")) == "left,left,left,stop", "All to left"
14
    assert left_join(("bright aright",
15
                      "ok")) == "bleft aleft,ok", "Bright Left"
16
    assert left_join(("brightness wright",)) == "bleftness wleft", "One phrase"
17
    assert left_join(("enough",
18
                      "jokes")) == "enough,jokes", "Nothing to replace"
19