How do you remove data in list in tinydb?

As you can see in my example above you have to remove from the list only the item. Once you have the new list (with the item removed), you need to store it again into tinyDB.

Again, use the Do it capability to check what is happening with your lists.

My bad. It's not removing all data, rather it's only removing that specific data but the problem is that when that data is remove the value of that index is now zero but my apps is trying to find a value to that index so it's not displaying the other content.

This is the error Message:


It seems you are trying to get the item 1 from an empty list...

Yes, but it's already empty since, It's was remove, Now I'm trying to do is when that data was remove it would be replace by the next data. so there's would be no error accur.

Hello, So I already resolve the problem with this one, but now the problem is, when I select all items in the list it supposedly removes all items in the list when i click buy, but it's not removing all items but it's displaying a error message.

So here for example: I have 9 items in my chart then select all of them

when it should be removing all item in the list intead this erro pop up

Then there would be 4 items in the list would stay instead of removing it on tinydb.

The error indicates that you are trying to remove the item 6 from a list with only 4 items.

Yes. That the error Im getting even when Im trying to remove is 9 items or all it would say that im trying to remove 6 items with the only items 4, but it's not it's 9

How are you removing those 9 items?

Here's the blocks:

It's working when im selected a 1, 2, 3, 4, or 5 items, but when removing all items or remove 6 items our of 9 list this message would pop up.

i can't use the if then, else if then, since it only removing 1 items even, I select 2 or more items.

You are removing fixed, when you are trying to remove item 6 from a list with, originally 9 items, and you already have deleted 5 items...your list has only 4, it gives you the error.

That's right and i don't know how to fix it. I'm confuse

? But, what item do you want to remove in each case? for example here:

What item do you want to remove? why the first one? how do you know the item you want to remove is the first one?

So when user add cart, the system would display it on the other screen there where we would know the item is the first one, so when removing it would remove the 1st one when I select it, the system would always replace the 1st items when it removed, so when 1st index was remove the 2nd index would replace it as 1st.

that is your problem....when removing an index, the others are moved...but, do you want to remove the complete list?

No what i want is to remove what I selected. not the entire list, I would delete it if I select all in the list.

Does the productName you add to a list correspond to the item you want to remove?

I mean, in this case, for example, is ProductName9 the element you want to delete in the other list (with index=1)?:

Yes,I want is before removing it on the list i want to store it first so I can display the users purchase into another screen.

Can i send you my apps, so you can try it?

For multiple deletion from a list by position, you have to loop from the end (last) to the first (index=1) by -1.

That way, you avoid the collapsing index numbers.

By the way, when you blocks start to look like saw blades, it's time to learn procedures and loops over lists.

If you have the productName you want to remove then you can do something like in the example I showed search the index of the item in the list by productName: