def gen_palindromes(l):
    lsol = []
    for i in range(len(l)):
        w = l[i]
        for w2 in l[i+1:]:
            check(w+w2, lsol)
            check(w2+w, lsol)
    return lsol

def check(w, l):
    if is_palindrome(w):
        if w not in l:
            l.append(w)
            
def is_palindrome(w):
    return w == w[::-1]
