| Total Complexity | 2 |
| Total Lines | 18 |
| Duplicated Lines | 0 % |
| Changes | 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 ( |
||
| 13 | left_join(("left", "right", "left", "stop")) == "left,left,left,stop" |
||
| 14 | ), "All to left" |
||
| 15 | assert left_join(("bright aright", "ok")) == "bleft aleft,ok", "Bright Left" |
||
| 16 | assert left_join(("brightness wright",)) == "bleftness wleft", "One phrase" |
||
| 17 | assert left_join(("enough", "jokes")) == "enough,jokes", "Nothing to replace" |
||
| 18 |