vendredi 2 juillet 2021

kwargs and args with if statements

I am wanting to create a function with a variabele lenght of arguments after the second argument using either args or kwargs. The aim of the function is to exclude newly created lists from a main lis I tried as follows:

def next_row_list1(list_a, list_b, *args):
non_matches = []
for i in list_a:
    if i not in list_b:
        if args:
            if i not in args:

                non_matches.append(i)
return non_matches
new_row_list1 = next_row_list1(row_list, ID01, ID02, ID03)

The error I get: 'TypeError: next_row_list() takes 3 positional arguments but 4 were given'.

Does anybody have a suggestion on how to incorporate the args and kwargs correctly?

Aucun commentaire:

Enregistrer un commentaire