Use the split() method to cut string after the character in Python. This split method returns the list of separated subtrings.
Python cut string after the character and Print example
Simple example code cut after “-” char in a given string. Must max split value 1 to split the string at the first occurrence of sep into a list.
Access this list’s 1 index element value to get a string with everything after the sep character.
s = "Python Programing - code example"
res = s.split("-", 1)[1]
print(res)
Output:
Do comment if you have any doubts and suggestions on this Python char string topic.
Note: IDE: PyCharm 2021.3.3 (Community Edition)
Windows 10
Python 3.10.1
All Python Examples are in Python 3, so Maybe its different from python 2 or upgraded versions.