I have a question about converting a string to a list. I know the following:
>>str1 - "123"
>>list(string)
['1','2','3']
but how to output:
['123']
I have a question about converting a string to a list. I know the following:
>>str1 - "123"
>>list(string)
['1','2','3']
but how to output:
['123']
Just use braces directly:
[str1]
Or if you want to stick with list
:
list((str1,))
does the same.
its easy
>>>str1 = "123"
>>>"".join(str1)
['123']
or: [str1]