A community for students.

Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing


  • 5 years ago

What is the difference b/w single quotes and double quotes? Why do I see them used interchangeably in numerous examples? When should single quotes be used and when double quotes?

  • This Question is Closed
  1. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    they accomplish the same function. it just depends on what youre trying to print. if youre trying to print something like. "He went to the store," said the boy. you would type print '"He went to the store", said the boy.' whenever you type the first quote it will look for the next instance of that particular character to terminate the string. so you can put double quotes inside single quote or single quotes inside double quotes. you can additionally use all the same kind of quotes and just put a "\" infront of the quotes you want to appear in the string. so the earlier example would be print "\"He went to the store,\" said the boy."

  2. carlsmith
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 1

    Nothing really. In Python, you can use either, but you must end the string with the same type of quotes as you start it with. It's useful because you'll often have quotes in strings. If you did name = 'O'Reilly' you'd get an error because the string 'O' is followed by some gibberish code, Reilly'. If you do name = "O'Reilly" everything is fine. You can use single quotes when you've got double quotes in a string. quote = 'He replies, "We're an autonomous workers collective".' If you want your string to span multiple lines, or if it contains both single and double quotes, you can use 'triple quotes', three single or three double quotes to open and three more of the same to close. both = ''' O'Reilly says "Hello" ''' long = ''' One line of text another one '''

  3. carlsmith
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 1

    Note: In triple quoted strings, newlines are preserved, even if they're blank lines. >>>print long One line of text another one >>> You've also got the escape characters. A backslashed character which has a special meaning. There's a few, but these are the common ones. \n = newline \t = tab \' = treat this single quote as a regular part of the string \" = same as above, but for a double quote \\ = same again, but for a backslash

  4. Not the answer you are looking for?
    Search for more explanations.

    • Attachments:

Ask your own question

Sign Up
Find more explanations on OpenStudy
Privacy Policy

Your question is ready. Sign up for free to start getting answers.

spraguer (Moderator)
5 → View Detailed Profile

is replying to Can someone tell me what button the professor is hitting...


  • Teamwork 19 Teammate
  • Problem Solving 19 Hero
  • You have blocked this person.
  • ✔ You're a fan Checking fan status...

Thanks for being so helpful in mathematics. If you are getting quality help, make sure you spread the word about OpenStudy.

This is the testimonial you wrote.
You haven't written a testimonial for Owlfred.