Search code examples
pythonpython-3.xprintingsublimetext3punctuation

Individually Add Punctuation (apostrophe) to a Printed Word?


I'm curious about adding punctuation without the need for a script/add-on, specifically for apostrophes since commas and ellipsis seem just fine by default.

So how would you individually add punctuation to the following code for the words "he's" and "it's":

print('I guess he's not going to be there right now, it's raining too hard...')

I'm brand new and assumed .split() was it, but it didn't work.


Solution

  • If you are only hoping to print out the text, then the issue you are running into is likely because the apostrophes use the same characters as the ones that indicate you are creating a string. In that case you can change the string characters to be "double quotes" so that the apostrophe/single quote doesn't cause issues.

    print("I guess he's not going to be there right now, it's raining too hard...")
    

    More generally you can also use an escape character to tell python that the internal apostrophes are not meant to denote the end of the string.

    print('I guess he\'s not going to be there right now, it\'s raining too hard...')
    

    For more information on escape characters: https://www.w3schools.com/python/gloss_python_escape_characters.asp