Contact: aviboots(AT)netvision.net.il
39,885 questions
51,811 answers
573 users
tupleList = [(3, 7), (1, 2, 0), (9, 8, 3, 4), (9, 2), (3, 1, 0), (1, 4, 7, 8)] N = 2 tupleList = [tpl for tpl in tupleList if len(tpl) != N] print(tupleList) ''' run: [(1, 2, 0), (9, 8, 3, 4), (3, 1, 0), (1, 4, 7, 8)] '''
tupleList = [(4, 9), (4, 0, 1), (5, 6), (1, 84, 83, 7), (4, 3), (6,)] N = 2 result = list(filter(lambda x : len(x) != N, tupleList)) print(result) ''' run: [(4, 0, 1), (1, 84, 83, 7), (6,)] '''