There are two ways to remove an item from within a list:
-
Using the command del
-
Using the method remove
Command del
Let's say we have the following list: listadetuplas = [(1, 2, 3), ('a', 'b', 'c')]
. To remove an item, without regard to what it is, use del
as follows:
del listadetuplas[1]
That is, we are removing the item / tuple present at index / position 1 from the list, regardless of which item / tuple is in that position - if the given position does not exist, it will return an error. This way, our list will look like this: [(1, 2, 3)]
.
Method remove
Given the same list example and its initial value, to remove a specific item, we can use the remove
method as follows:
listadetuplas.remove((1, 2, 3))
That is, we are specifically removing the tuple (1, 2, 3)
from within the list, regardless of which position / index it is in now. This way, our list would look like this: [('a', 'b', 'c')]
.
[Edited]
So, just get the class list
and convert the tuple into a list, like this:
list(('2019-02-20', '12:30', 'iCageDoree', 'Pedro Ruivo, lisbon, (heating; doors; windows), 5*, 75, 2019-03-22, 09:15, 3523.0'))
or
list([('2019-02-20', '12:30', 'iCageDoree', 'Pedro Ruivo, lisbon, (heating; doors; windows), 5*, 75, 2019-03-22, 09:15, 3523.0')][0])
I hope I have helped!