-1

For example I have this tuple:

(('Samsung J1',), ('Cloudfone Thrill Boost',))

I want to convert it to a string so it will look like this:

Samsung J1
Cloudfone Thrill Boost

I tried doing:

''.join(variablenamefortuple) 

and it did not work just then I realized that it is a list of tuples so I tried mykhal's answer here: Python - convert list of tuples to string

But the strip function only removes from the ends so the output will be like this:

'Samsung J1',), ('Cloudfone Thrill Boost',

How do I remove the extra parentheses as well as the commas and quotation marks? Thanks:)

1 Answers1

0

You can do it like this (a small variation on @RafaelC comment):

s = (('Samsung J1',), ('Cloudfone Thrill Boost',))
print('\n'.join([k for k, in s]))

Output

Samsung J1
Cloudfone Thrill Boost
Dani Mesejo
  • 55,057
  • 6
  • 42
  • 65