'How to delete items from dynamodb list

import boto3
dynamodb = boto3.resource('dynamodb')
table = dynamodb.Table('myowntable')
response = []
response_table = table.get_item(Key={'id': '19'})
        if 'Item' in response_table and response_table['Item']:
            response.append(response_table['Item'])

listofvalues = [1,2,3]
for i in listofvalues:
    id_index_delete = str(response[0]['myList'].index(i))
    query = "REMOVE myList[" + id_index_delete + "]"
    table.update_item(
                    Key={
                        'id': '19'
                    },
                    UpdateExpression=query
                )



Solution 1:[1]

If you turn your list into a map, you can then delete items based on the map key and do all deletes in one operation.

Old: [1,2,3]

New: {“1”:1,”2”:2,”3”:3}

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Ross Williams