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

17 lines
302 B
Python
Raw Permalink Normal View History

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