Light Mode
Dark Mode
Split Pairs Mission

Hi, I don't understand what is wrong with my code. I thought it would append every pair that I form, but somehow it only appends the last pair.

I'm sure I'm taking too many lines to do it too, but I'll learn from reading the solutions (after i manage to clear this...). Thank you!

def split_pairs(a):

if len(a)%2==0:
    None
else:
    a = a + "_"

b = list(a)
r = len(b)//2
for i in range(r):
    ans = []
    pair = b[2*i]+b[2*i+1]
    ans.append(pair)
return ans
Created: Dec. 20, 2020, 2:34 p.m.
Updated: Dec. 20, 2020, 3:56 p.m.
0
15
User avatar
Adrian_Goh