The code below,
part is one of ('frodo', 'fradi'), ('frodo', 'crodo'), ('frodo', 'abc123'), ('frodo', 'abc123'), ('frodo', 'frodoc'), ('fradi', 'crodo'), ('fradi', 'abc123'), ('fradi', 'abc123'), ('fradi', 'frodoc'), ('crodo', 'abc123').
ban_group is ["fr*d*", "abc1**"]
Function solution checks if part[i] can be ban_group[i].
What I expected was
when part is ('frodo', 'fradi'), part[0] can be ban_group[0] and part[1] can't be ban_group[1]. So it's False.
when part is ('frodo', 'abc123'), part[0] can be ban_group[0] and part[1] can be ban_group[1]. So it's True, so add part to list candidates.
But it doesn't work as I expected. I really don't get what part is problem.
Can you help me with this?
from itertools import combinations
def check_id(user, ban):
    for i in range(len(ban)):
        if ban[i] == '*':
            continue
        elif user[i] != ban[i]:
            return False
    return True
candidates = []
def solution(user_group, ban_group):
    for part in combinations(user_group, len(ban_group)):
        for i in range(len(part)):
            if check_id(part[i], ban_group[i]) is True:
                candidates.append(part)
    return candidates
print(solution(["frodo", "fradi", "crodo", "abc123", "frodoc"], ["fr*d*", "abc1**"]))
 
     
     
    