Skip to content

Commit b1657a2

Browse files
author
boraxpr
committed
bite 104
1 parent 2144d55 commit b1657a2

File tree

4 files changed

+41
-105
lines changed

4 files changed

+41
-105
lines changed

104/pipe.py

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
message = """Hello world!
2+
We hope that you are learning a lot of Python.
3+
Have fun with our Bites of Py.
4+
Keep calm and code in Python!
5+
Become a PyBites ninja!"""
6+
7+
def split_in_columns(message=message):
8+
"""Split the message by newline (\n) and join it together on '|'
9+
(pipe), return the obtained output string"""
10+
seq = []
11+
joinby = "|"
12+
for each in message.split("\n"):
13+
seq.append(each)
14+
return joinby.join(seq)
15+
pass
16+
17+
# print(split_in_columns(message))

104/test_pipe.py

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
from pipe import split_in_columns
2+
3+
4+
def test_split_in_columns_default_message():
5+
# one line string but a nice way in Python to wrap over multiple lines
6+
expected = ('Hello world!|We hope that you are learning a lot of Python.|'
7+
'Have fun with our Bites of Py.|Keep calm and code in Python!'
8+
'|Become a PyBites ninja!')
9+
10+
actual = split_in_columns()
11+
assert actual == expected
12+
13+
14+
def test_split_in_columns_on_other_message():
15+
expected = 'Hello world:|I am coding in Python :)|How awesome!'
16+
17+
message = 'Hello world:\nI am coding in Python :)\nHow awesome!'
18+
actual = split_in_columns(message)
19+
20+
assert actual == expected
21+
22+
test_split_in_columns_default_message()
23+
test_split_in_columns_on_other_message()
24+

130/cars.py

-59
This file was deleted.

130/test_cars.py

-46
This file was deleted.

0 commit comments

Comments
 (0)