Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Converting Tuple of integers and strings to just a string

Tags:

python

I want to convert a tuple which contains strings and integers into a string, I have tried using the '.join' method but this only seems to work for a tuple of strings.

Can anyone help me? I am using Python 3.5, thanks!

like image 311
RonB7 Avatar asked Jul 25 '16 18:07

RonB7


2 Answers

This Might Help

>>> a = ( "aty",3,"bob",5,6)
>>> tuple(map( str , a ) )
('aty', '3', 'bob', '5', '6')
like image 164
Athar Avatar answered Nov 16 '22 15:11

Athar


" ".join(map(str,my_list))

I guess ...

or " ".join(str(x) for x in my_list)

like image 15
Joran Beasley Avatar answered Nov 16 '22 14:11

Joran Beasley