+ 2
Iterate over dictionary.
data = [{'id': 1, 'name': 'aaaa'}, {'id': 2, 'name': 'bbbb'}, {'id': 3, 'name': 'cccc'}, {'id': 4, 'name': 'dddd'}, {'id': 5, 'name': 'eeee'}, {'id': 6, 'name': 'ffff'}] for d in data: for key in d: print (d['id'], d['name']) This prints all the item in the list containing dictionary but I want to print from id = 3 to id = 6.
2 Respostas
+ 7
You should change the first line to:
for d in data[2:]:
+ 1
Thanks Kuba. Always been a great help.