I am trying to extract data's from list of list of tuples but I am having an issue because they have different output from normal for loop and this list comprehension loop:
Here is my sample data and actually came from my database and return it as unicode and I just converted as a list:
[[(1970, u'0238'), (1971, u'0243'), (2110, u'0929'), (2108, u'0930'), (1972, u'0932'), (1973, u'0934')]]
[[(1970, u'0238'), (1971, u'0243'), (2110, u'0929'), (2108, u'0930'), (1972, u'0932'), (1973, u'0934')]]
[[(2108, u'0930')], [(3012, u'1')]]
[[(2108, u'0930')], [(3012, u'1')]]
[[(2108, u'0930')], [(3012, u'1')]]
[[(2108, u'0930')], [(3012, u'1')]]
And by using my simple for loop which is the correct output:
for i in datas:
print i
[(1970, u'0238'), (1971, u'0243'), (2110, u'0929'), (2108, u'0930'), (1972, u'0932'), (1973, u'0934')]
[(1970, u'0238'), (1971, u'0243'), (2110, u'0929'), (2108, u'0930'), (1972, u'0932'), (1973, u'0934')]
[(2108, u'0930')]
[(3012, u'1')]
[(2108, u'0930')]
[(3012, u'1')]
[(2108, u'0930')]
[(3012, u'1')]
[(2108, u'0930')]
[(3012, u'1')]
But if I will use the list comprehension style the out will be now different:
print [i for i in datas]
[[(1970, u'0238'), (1971, u'0243'), (2110, u'0929'), (2108, u'0930'), (1972, u'0932'), (1973, u'0934')]]
[[(1970, u'0238'), (1971, u'0243'), (2110, u'0929'), (2108, u'0930'), (1972, u'0932'), (1973, u'0934')]]
[[(2108, u'0930')], [(3012, u'1')]]
[[(2108, u'0930')], [(3012, u'1')]]
[[(2108, u'0930')], [(3012, u'1')]]
[[(2108, u'0930')], [(3012, u'1')]]
Any advice or suggestions thanks in advance!