How to split string that is a part of a tuple list in python
Question:
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
Answers:
There probably is a more pythonic way of doing this but the following works:
for pair in my_list:
print(pair[0])
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
There probably is a more pythonic way of doing this but the following works:
for pair in my_list:
print(pair[0])