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
Post a Comment