Hi i have a lists like this
['ID 1d6b:0002']
['ID 1d6b:0002']
['ID 1d6b:0001']
['ID 1d6b:0001']
['ID 1d6b:0001']
['ID 1d6b:0001']
['ID 1d6b:0001']
['ID 0b38:0010']
['ID 093a:2510']
I want this to one list.Please help me out with this
Hi i have a lists like this
['ID 1d6b:0002']
['ID 1d6b:0002']
['ID 1d6b:0001']
['ID 1d6b:0001']
['ID 1d6b:0001']
['ID 1d6b:0001']
['ID 1d6b:0001']
['ID 0b38:0010']
['ID 093a:2510']
I want this to one list.Please help me out with this
You can do:
old_list = [
['ID 1d6b:0002'],
['ID 1d6b:0002'],
['ID 1d6b:0001'],
['ID 1d6b:0001'],
['ID 1d6b:0001'],
['ID 1d6b:0001'],
['ID 1d6b:0001'],
['ID 0b38:0010'],
['ID 093a:2510']]
new_list = [x[0] for x in old_list]
This uses list comprehension to create a new list that contains the first elements ([0]) all on the lists in the old list.
Hope that helps.