python split on last occurrence code example
Example 1: python reverse split only once
s.rsplit(',', 1)
s.rpartition(',')
Example 2: python split on first occurrence
str.split([sep[, maxsplit]])
s = "123mango abcd mango kiwi peach"
s.split("mango", 1)
['123', ' abcd mango kiwi peach']
>>> s.split("mango", 1)[1]
' abcd mango kiwi peach'
Example 3: rsplit string from last
'sayanand'.rsplit('a', 2)
>>> ['say', 'n', 'nd']