Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Loops with Even Increments solution in Clear category for Split Pairs by Abrar_Ahmed
def split_pairs(a):
index = 0 #start range index used in loop
output = [] #string pairs to be appended to this list
for digit in range(2,len(a)+2,2): #to get digit index 2,4,6...
#slicing ranges 0:2, 2:4..adding "_" where not a pair
output.append(a[index:digit] if len(a[index:digit]) == 2 else a[index:digit]+'_')
#incrementing index counter with even number
index = digit
return output
July 23, 2021