You could use
I just realised the index digits should be in the same tuple as the rest of the items.
enumerate
to add the digits to your result.result = [('Algeria', 17), ('Afghanistan', 2), ('Albania', 0)] print([(index, value) for index, value in enumerate(result, 1)])
Output:[(1, ('Algeria', 17)), (2, ('Afghanistan', 2)), (3, ('Albania', 0))]
I just realised the index digits should be in the same tuple as the rest of the items.
result = [('Algeria', 17), ('Afghanistan', 2), ('Albania', 0)] print([(index, *value) for index, value in enumerate(result, 1)])
Output:[(1, 'Algeria', 17), (2, 'Afghanistan', 2), (3, 'Albania', 0)]