dez = {(1, 2, 3, 4), 5, 6}
you need to remove any element in the tuple that is in the set: 1, 2, 3, or 4
dez = {(1, 2, 3, 4), 5, 6}
you need to remove any element in the tuple that is in the set: 1, 2, 3, or 4
You cannot delete an item from a tuple, because this type is immutable. You can remove a tuple from the set, and instead create a new tuple without some element.
>>> dez = {(1, 2, 3, 4), 5, 6} >>> dez.remove((1, 2, 3, 4)) >>> dez set([5, 6]) >>> dez.add((1, 2, 3)) >>> dez set([5, 6, (1, 2, 3)]) tuple(el for el in tup if el != 4) - jfsSource: https://ru.stackoverflow.com/questions/584705/
All Articles