Answers for "python split multiple chars"

5

multi split python

str = 'Lorem; ipsum. dolor sit amet, consectetur adipiscing elit.'
str = str.split(',')
print(str) # Output ['Lorem; ipsum. dolor sit amet', ' consectetur adipiscing elit.']

import re
str = 'Lorem; ipsum. dolor sit amet, consectetur adipiscing elit.'
str = re.split(r';|,|.', str)
print(str) # Output ['Lorem', ' ipsum', ' dolor sit amet', ' consectetur adipiscing elit', '']
Posted by: Guest on May-04-2020
1

split a string with 2 char each in python

a_string = "abcde"

n = 2
split_strings = [a_string[index : index + n] for index in range(0, len(a_string), n)]
Posted by: Guest on September-19-2021

Code answers related to "python split multiple chars"

Python Answers by Framework

Browse Popular Code Answers by Language