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

c - Compilation of a code: unkown type name string -

java - Bypassing "final local variable defined in an enclosing type" -

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