Sep-02-2018, 05:22 AM
If there are only two symbols you want to split on then you can do replace and then split.
>>> a = 'spam_ham-bacon_eggs' >>> a.replace('_', '-').split('-') ['spam', 'ham', 'bacon', 'eggs']It will not give you any errors when symbols are not present so no need to catch error with try...except.
I'm not 'in'-sane. Indeed, I am so far 'out' of sane that you appear a tiny blip on the distant coast of sanity. Bucky Katt, Get Fuzzy
Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.
Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.