How to remove everything before last occurrence of character in a string with Python

1 Answer

0 votes
str_ = 'python_java_c_c++_c#'

char = 'a'

str_ = char + str_.rsplit(char, 1)[1]

print(str_)  


 
 
'''
run:
 
a_c_c++_c#

'''

 



answered Jul 8, 2022 by avibootz
...