I currently have this multi-dimensional list and I am trying to extract the first column from it:
>>> print(data)
[['com.borderstylo.retrollect', '0', '0'], ['aabasoft.presents.goldprice', '0', '0'], ['aberl.vlc.light.mote', '0', '0']]
when I use
sitelist = []
for row in data:
sitelist.append(row[0])
print(sitelist)
I get the output below, which is what i am after.
['com.borderstylo.retrollect', 'aabasoft.presents.goldprice', 'aberl.vlc.light.mote']
However, when i use
sitelist = []
sitelist = (row[0] for row in data)
print(sitelist)
type(sitelist)
I get the output below instead, which is a generator object. What is a generator object and why does the 1st set of code return something different from the 2nd? both appear very similar.
<generator object <genexpr> at 0x001A9E10>
generator
Many thanks for replies. Newbie at python but really wanting to learn.