Split on the last delimiter
Write a Python program to split a string on the last occurrence of a delimiter.
"l,e,a,r,n,I,n,g,p,y,t,h,o,n"
['l,e,a,r,n,I,n,g,p,y,t,h,o', 'n']
Approach
rsplit(",", 1)splits once, from the right.
Solution
text = "l,e,a,r,n,I,n,g,p,y,t,h,o,n"print(text.rsplit(",", 1))['l,e,a,r,n,I,n,g,p,y,t,h,o', 'n']
Learn the concept
New to this topic? Read the lesson, then come back.