The data:
list = [\'a\',\'b\',\'x\',\'d\',\'s\']
I want to create a string str = \"abxds\". How can I do that?
Right now I am doing
>>> theListOfChars = ['a', 'b', 'x', 'd', 's']
>>> ''.join(theListOfChars)
'abxds'
BTW, don't use list
or str
as variable names as they are names of built-in functions already.
(Also, there is no char
in Python. A "character" is just a string of length 1. So the ''.join
method works for list of strings as well.)