How would I delete everything after a certain character of a string in python? For example I have a string containing a file path and some extra characters. How would I delete e
I think it's easy to create a simple lambda function for this.
mystrip = lambda s, ss: s[:s.index(ss) + len(ss)]
Can be used like this:
mystr = "this should stay.zipand this should be removed." mystrip(mystr, ".zip") # 'this should stay.zip'