Can we use a single quotation in string? I can, What are the situations? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Can we use a single quotation in string? I can, What are the situations?

11th Jul 2023, 4:29 PM
Monec
Monec - avatar
3 Answers
+ 8
Hi Omar You can use single or double quotes. Here are situations where you would choose to use one or the other: Example 1: 'He said, "See ya," and closed the door.' Example 2: "They said, 'We will miss you,' as he left." Use both single and double quotes when you need to include quotes within quotes. If you use single quotes, make sure to start and end with the same type, and the same applies to double quotes.
11th Jul 2023, 5:51 PM
Chris Coder
Chris Coder - avatar
+ 5
Everyone can use single quote not only you
11th Jul 2023, 4:41 PM
A͢J
A͢J - avatar
+ 1
Python is doesn't differ between a single quote or a double code in a string. The output will be the same, however, one thing that you need to be careful is that many other languages, make a difference between a single quote and a double quote. Make sure to not use a combination of both, as it can make the code hard to read.
12th Jul 2023, 1:09 AM
Danish Zubair
Danish Zubair - avatar