Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others


0 votes
in Technique[技术] by (71.8m points)

python - How do I print strings in a variable length list?

I have a function that produces an array that looks like this:

[(1, 3, 'test data')]

Any data in that array can change so I can't just do


I need to print all of the strings in the array. Any ideas are appreciated. Thanks!

Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I need to print anything in the apostrophes

In other words, you want to print strings:

for some_tuple in the_list:
    for element in some_tuple:
        # check if element is a string
        if isinstance(element, str):

Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share