Jun-16-2019, 10:05 AM
Hi,
first of all: your post would be _much_ more readable if you would write words correctly in upper and lower case and especially would use punctuation.
in Python you can iterate directly over list and tuples, as the are iterable. So no need for
I do not really understand what the final output should be. You a list of three tuples and want to get ... what? The example in your 2nd code block doesn't make to much sense... Do you want a dict for each item in the list, which would be three dicts as per your example. Or do you want to get a dict of dicts?
And why to do need a dict at all? Your input, the list of tuples, is already ordered, isn't it?
And did you check the documentation of your data source if this isn't able already to provide a dict instead of a list?
Regards, noisefloor
first of all: your post would be _much_ more readable if you would write words correctly in upper and lower case and especially would use punctuation.
in Python you can iterate directly over list and tuples, as the are iterable. So no need for
range
or len
or anything. Just do for item in iterable:
.I do not really understand what the final output should be. You a list of three tuples and want to get ... what? The example in your 2nd code block doesn't make to much sense... Do you want a dict for each item in the list, which would be three dicts as per your example. Or do you want to get a dict of dicts?
And why to do need a dict at all? Your input, the list of tuples, is already ordered, isn't it?
And did you check the documentation of your data source if this isn't able already to provide a dict instead of a list?
Regards, noisefloor