Converting tuple to String

B

Byte

Is their a command to convert a tuple to string? e.g.

xyz = "Hello", "There"
print xyz

Is their any way of getting print to see xyz as being one string i.e.
"Hello There" rather than "Hello" and "There", despite "Hello" and
"There" being, in reality, seperate?

Thanks in advance,
-- /usr/bin/byte
 
D

Daniel Nogradi

Is their a command to convert a tuple to string? e.g.
xyz = "Hello", "There"
print xyz

Is their any way of getting print to see xyz as being one string i.e.
"Hello There" rather than "Hello" and "There", despite "Hello" and
"There" being, in reality, seperate?

Try

one_big_string = ''.join( xyz )
print one_big_string

Hope this helps.
 
S

Stefan Lang

Is their a command to convert a tuple to string? e.g.

xyz = "Hello", "There"
print xyz

Is their any way of getting print to see xyz as being one string
i.e. "Hello There" rather than "Hello" and "There", despite "Hello"
and "There" being, in reality, seperate?

Use the "join" method of strings:

print ' '.join(xyz)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,294
Messages
2,571,511
Members
48,202
Latest member
ClaudioVil

Latest Threads

Top