Split Strings

Python

def solution(s):
    solution_array = []
    for i in range(0, len(s), 2):
        string = s[i] + (s[i+1] if i+1 < len(s) else '_')
        solution_array.append(string)
    return solution_array

Tags

  1. python (Private)
  2. 6-kyu (Private)
  3. codewars (Private)
  4. answer (Private)