How to iterate through a list of string tuples of varying lengths in Python?
4
I'm trying to iterate through a list of Tuples which are of varying length. However, I'm just trying to figure something out regarding it.
test_list = [("rock", "paper", "scissors"),("go","fish"),("uno")]
for each_tuple in test_list:
for each_word in each_tuple:
print(each_word)
This prints
rock
paper
scissors
go
fish
u
n
o
What is a solution I could use such that uno is printed as "uno" and not as u n o as separate letters. I understand why this is occuring, but I'm not sure what I should be implementing to "check" whether or not the tuple only has a single element in it vs. multiple.
python
Add a comment
|