I have a nested list main_category, each nested list is a unicode string of business names. The first five lines of the nested lists are below:
[[u'Medical Centers', u'Health and Medical'],
[u'Massage', u'Beauty and Spas'],
[u'Tattoo', u'Beauty and Spas'],
[u'Music & DVDs', u'Books, Mags, Music and Video', u'Shopping'],
[u'Food', u'Coffee & Tea']]
So I want to get the first element of every list, and I have tried list comprehension, zip, but nothing works.
new_cate = [d[0] for d in main_category]
lst = zip(*main_category)[0]
But all of them give me
IndexErrorTraceback (most recent call last)
<ipython-input-49-4a397c8e62fd> in <module>()
----> 1 lst = zip(*main_category)[0]
IndexError: list index out of range
I really don't know what is wrong with this. So could anyone help? Thanks so much!