How to add single and double quotes to a string in Python

4 Answers

0 votes
s = '"It\'s a nice option!" Save us some time.';
 
print(s)
 
 
'''
run:
 
"It's a nice option!" Save us some time.
 
'''

 



answered Mar 12, 2025 by avibootz
edited Mar 12, 2025 by avibootz
0 votes
s = "\"It's a nice option!\" Save us some time.";
 
print(s)
 
 
'''
run:
 
"It's a nice option!" Save us some time.
 
'''

 



answered Mar 12, 2025 by avibootz
0 votes
s = """"It's a nice option" Save us some time. Try it""";
 
print(s)
 
 
'''
run:
 
"It's a nice option" Save us some time. Try it
 
'''

 



answered Mar 12, 2025 by avibootz
0 votes
s = '''"It's a nice option", Save us some time. Try it free''';
 
print(s)
 
 
'''
run:
 
"It's a nice option", Save us some time. Try it free
 
'''

 



answered Mar 12, 2025 by avibootz

Related questions

1 answer 183 views
1 answer 219 views
1 answer 174 views
1 answer 206 views
1 answer 194 views
3 answers 482 views
1 answer 261 views
...