We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent bf13a8d commit 11dcb9eCopy full SHA for 11dcb9e
.gitignore
@@ -44,3 +44,4 @@
44
/62/README.md
45
/86/README.md
46
/78/README.md
47
+/162/README.md
162/fill.py
@@ -0,0 +1,8 @@
1
+HTML_SPACE = ' '
2
+
3
4
+def prefill_with_character(value, column_length=4, fill_char=HTML_SPACE):
5
+ """Prepend value with fill_char for given column_length"""
6
+ return (column_length-len(str(value)))*fill_char+str(value)
7
8
+# prefill_with_character("cxxx")
162/test_fill.py
@@ -0,0 +1,21 @@
+import pytest
+from fill import prefill_with_character, HTML_SPACE
+DIFF_FILL = 'x'
+@pytest.mark.parametrize("value, len_, fill, result", [
9
+ (1, 4, HTML_SPACE, f'{HTML_SPACE*3}1'),
10
+ (20, 4, HTML_SPACE, f'{HTML_SPACE*2}20'),
11
+ (315, 4, HTML_SPACE, f'{HTML_SPACE}315'),
12
+ (1239, 4, HTML_SPACE, '1239'),
13
+ (8, 5, DIFF_FILL, f'{DIFF_FILL*4}8'),
14
+ (12, 5, DIFF_FILL, f'{DIFF_FILL*3}12'),
15
+ (139, 5, DIFF_FILL, f'{DIFF_FILL*2}139'),
16
+ (9827, 5, DIFF_FILL, f'{DIFF_FILL}9827'),
17
+ (12345, 5, DIFF_FILL, '12345'),
18
+])
19
+def test_prefill_with_character(value, len_, fill, result):
20
+ assert prefill_with_character(value, column_length=len_,
21
+ fill_char=fill) == result
0 commit comments