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