mercredi 24 février 2016

Append to list if not repeated

I'm doing a program and in one section of it I create new lists and append them to a general list. Nevertheless I would like to create a if-statement or something similar that would stop the append operation if that list is already in the general list. Any suggestions on how can I rewrite the code for this propose?

This is just an example of one of the functions I'm using to append.

def remove(sequence):
    for i in range(len(sequence)):
        remove = list(sequence)
        del remove[i]
        stack.append(remove)

Aucun commentaire:

Enregistrer un commentaire