File tree 4 files changed +41
-105
lines changed
4 files changed +41
-105
lines changed Original file line number Diff line number Diff line change
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))
Original file line number Diff line number Diff line change
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:\n I am coding in Python :)\n How 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
+
Load Diff This file was deleted.
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments