There are two ways to remove an item from within a list:
Through command del
By the method remove
Commando del
Let’s say we have the following list: listadetuplas = [(1, 2, 3), ('a', 'b', 'c')]
. To remove an item, regardless of what it is, use the del
as follows:
del listadetuplas[1]
That is, we are removing the item/tuple present in index/position 1 from the list, no matter which item/tuple is in that position - if the given position does not "exist", an error will be returned. That way, our list will look like this: [(1, 2, 3)]
.
Method remove
Considering the same example of list and its initial value, to remove a specific item, we can use the method remove
as follows:
listadetuplas.remove((1, 2, 3))
That is, we are specifically removing the tuple (1, 2, 3)
from within the list, no matter what position/index it is in now. That way, our list would look like this: [('a', 'b', 'c')]
.
[Edited]
So just take 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’ve helped!
Well, what happens here is that what you’re using to enter the data into that list, is sending the data as a dropdown. Instead of getting around the problem with more lines of code, I suggest you fix how to send the data to the list so that it is not inserted as a single file. Anyway the solution presented above works perfectly.
– Jorge Gomes