Ask Your Question
0

converting a list to a text without copy-pasting

asked 2014-10-01 05:02:41 -0500

algebraicallyclosed gravatar image

Hi, I have a list and I need to convert it to a text but i want to call this list, so I don't want to copy and paste the result in text = " "

I tried text = list(U) (just assume that U is callable, so list(U) gives anything in U as a list) but it didn't work.

Can anyone suggest a way?

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted
0

answered 2014-10-16 11:03:18 -0500

algebraicallyclosed gravatar image

updated 2014-10-16 11:05:25 -0500

Thank you for answering. However, not those, but this worked; where

L = list(U); text = ''+str(L)

-For anyone who is also interested:)

edit flag offensive delete link more
0

answered 2014-10-01 07:31:27 -0500

calc314 gravatar image

updated 2014-10-01 07:32:37 -0500

I will assume your list consists of strings. You can build a string using a loop.

L=['a','b','c']
text=''
for s in L: 
     text+=s

Or, more succinctly, you can use the python join command:

newtxt=''.join(L)
print newtxt
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2014-10-01 05:02:41 -0500

Seen: 55 times

Last updated: Oct 16 '14