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 182 views
1 answer 217 views
1 answer 173 views
1 answer 203 views
1 answer 192 views
3 answers 480 views
1 answer 259 views
...