1
0
Fork 0
mirror of https://gitlab.com/mfocko/CodeWars.git synced 2024-11-27 19:06:13 +01:00
CodeWars/6kyu/split_strings/solution.py
Matej Focko fc899b0b02
chore: initial commit
Signed-off-by: Matej Focko <mfocko@redhat.com>
2021-12-28 16:19:58 +01:00

16 lines
302 B
Python

def solution(s):
if len(s) == 0:
return []
elif len(s) % 2 == 1:
s += "_"
arr = []
index = -1
for i, letter in enumerate(s):
if i % 2 == 0:
index += 1
arr.append(letter)
else:
arr[index] += letter
return arr