python - How do I split multiple characters without using any imported libraries? -



python - How do I split multiple characters without using any imported libraries? -

the string is:

line = 'a tuba!'

i want remove spaces , exclamation point when utilize .split() function, output follows:

line = ['a','but','tuba']

i want without using imported libraries, basic code.

first, remove ! using str.replace() , split string using str.split().

line = 'a tuba!' line = line.replace('!', '').split(' ') print line

output:

['a', 'but', 'tuba']

python split

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -