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 97 views
1 answer 136 views
1 answer 107 views
1 answer 107 views
1 answer 113 views
3 answers 321 views
1 answer 192 views
...