Run
import re str = 'apple,,orange,,,grape' #split string by , chunks = re.split(',+', str) print(chunks)
Output