Complete the code to limit the number of items returned to 5.
response = table.scan(Limit=[1])The Limit parameter controls how many items DynamoDB returns in one call. Setting it to 5 returns only 5 items.
Complete the code to start scanning from the last evaluated key stored in last_key.
response = table.scan(ExclusiveStartKey=[1])None which means start from the beginning.The ExclusiveStartKey parameter tells DynamoDB where to continue scanning from. You pass the last key you got from the previous scan.
Fix the error in the code to correctly check if there are more items to scan.
if 'LastEvaluatedKey' in response and response[1] 'LastEvaluatedKey' is not None: last_key = response['LastEvaluatedKey']
== which checks equality, not inequality.is which is not correct for this check.You want to check that LastEvaluatedKey exists and is not None. Using != correctly tests that.
Fill both blanks to scan with a limit of 10 and start from the last evaluated key.
response = table.scan(Limit=[1], ExclusiveStartKey=[2])
Set Limit to 10 to get 10 items per scan, and use last_key to continue from where the last scan ended.
Fill all three blanks to create a loop that paginates through all items with a limit of 3.
last_key = None items = [] while True: response = table.scan(Limit=[1], ExclusiveStartKey=[2]) items.extend(response['Items']) if 'LastEvaluatedKey' not in response or response['LastEvaluatedKey'] is None: break last_key = response[[3]]
last_key correctly.This loop scans the table in pages of 3 items. It uses last_key to continue scanning and stops when no more keys are returned.