[Solved] Separate string in Python [closed]

[ad_1]

You can use regular expressions:

import re

s = [el for el in re.split('([\W+])', '☕ Drink the ❶ best ☕coffee☕') if el.strip()]
print(s)

output:

['☕', 'Drink', 'the', '❶', 'best', '☕', 'coffee', '☕']

2

[ad_2]

solved Separate string in Python [closed]