Last active
November 12, 2017 09:09
-
-
Save pykong/f69a4a3101562de4c892dc2d761f7057 to your computer and use it in GitHub Desktop.
Also, note the elegant usage of an index to slice string. https://stackoverflow.com/questions/14496006/finding-last-occurrence-of-substring-in-string-replacing-that
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
old_string = "this is going to have a full stop. some written sstuff!" | |
k = old_string.rfind(".") | |
new_string = old_string[:k] + ". - " + old_string[k+1:] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment