-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconcatenate.py
35 lines (25 loc) · 909 Bytes
/
concatenate.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
def concatenate(input):
index = 0
if len(input) == 0:
return ''
output = input[index]
while index < len(input) - 1:
output += " "
output += input[index+1]
index += 1
return output
def testcase():
value = concatenate([])
assert value == "", \
f"expected return value was an empty string, but function returned {value}"
value = concatenate(["", "", ""])
assert value == " ", \
f"expected return value was an \" \", but function returned {value}"
value = concatenate(["Hi", "there"])
assert value == "Hi there", \
f"expected return value was an \"Hi There\", but function returned {value}"
value = concatenate(["Test", "Set", "Three"])
assert value == "Test Set Three", \
f"expected return value was an \"Test Set Three\", but function returned {value}"
print("All tests passed.")
#testcase()