python - Splitting a string in two parts -


i want split string in 2 parts this:

>>> label = ('a1') ['a', '1'] 

is there method in python?

i tried:

>>> label = label.split(',') ['a1'] 

as can see comma not printed.

you can use list:

>>> label = 'a1' >>> list(label) ['a', '1'] >>> 

list iterate on string , collect characters new list.

also, cannot use str.split here because method designed split on characters/substrings , remove them resulting list. example, 'a b c'.split() split on whitespace , remove characters returned list, ['a', 'b', 'c']. want break string individual characters while still keeping of them.


Comments

Popular posts from this blog

python - mat is not a numerical tuple : openCV error -

c# - MSAA finds controls UI Automation doesn't -

wordpress - .htaccess: RewriteRule: bad flag delimiters -