Home > Back-end >  How to split string that is a part of a tuple list in python
How to split string that is a part of a tuple list in python

Time:05-06

I have a list of string tuples (list[tuple[str, str]]) like this [('JimKing', 'TheKing'), ('GadgetKing', 'EnergyKing'), ('ThingKing', 'Energyking')] and I would like to split and print the first string in the tuples eg list[0] = 'JimKing' Thanks in advance

CodePudding user response:

There probably is a more pythonic way of doing this, but the following works:

for pair in my_list:
   print(pair[0])
  • Related