8

I was wondering if python had a built in function similar to

string->list 

and list->string in scheme.

So for example I would like to turn 'abc' into ['a','b','c'] and vice versa using a built in function.

2 Answers 2

13

String to list:

>>> list('abc') ['a', 'b', 'c'] 

List to string:

>>> ''.join(['a', 'b', 'c']) 'abc' 
Sign up to request clarification or add additional context in comments.

Comments

0

Split using a list comprehension [c for c in theString] .. and join them again using ''.join(theList). Other ways exist.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.