Home > database >  How to convert a List with two capsuled tuples insed it to list?
How to convert a List with two capsuled tuples insed it to list?

Time:11-14

I have a list which has capsuled two tuples inside of it.

Example:

[(('100.100.100.100', 11111), ('100.100.100.100', 11111))]

And I need to convert it like this:

['100.100.100.100', '100.100.100.100']

Thanks for the help!

CodePudding user response:

Use a comprehension:

l1 = [(('100.100.100.100', 11111), ('100.100.100.100', 11111))]
l2 = [l[0] for l in l1[0]]
print(l2)

# Output:
['100.100.100.100', '100.100.100.100']
  • Related