Using quotation marks inside quotation marks

You could do this in one of three ways:

  1. Use single and double quotes together:

    print('"A word that needs quotation marks"')
    "A word that needs quotation marks"
    
  2. Escape the double quotes within the string:

    print("\"A word that needs quotation marks\"")
    "A word that needs quotation marks" 
    
  3. Use triple-quoted strings:

    print(""" "A word that needs quotation marks" """)
    "A word that needs quotation marks" 
    

Leave a Comment