+ 2

Why the input is double and the output is single string?

3rd Sep 2016, 6:36 PM
Courage Lartey
Courage Lartey - avatar
4 ответов
+ 2
Output of the console is always a string in single quotes. But you can declare strings with single or double quotes. Just be careful, when in your string is a quote included, therefore are special rules.
3rd Sep 2016, 8:38 PM
Amarie
+ 1
thanks everyone
5th Sep 2016, 10:37 AM
Courage Lartey
Courage Lartey - avatar
0
Python doesn't care if you use single or double quotes, as long as you use the same type of quotes to start and end your string. Python will just print the string with single quotes since it doesn't make any distinction. If you use quotation marks inside your string, surround it with the other type of quotation marks (single or double) than the ones you used to surround your string, or use a backslash to escape those characters.
4th Sep 2016, 1:24 AM
Kevin
0
imagine if u had to give an apostrophe character inside the string,.. (a single single quote).. Then surrounding the whole string with a double quote would be convenient way around. this is jus a scenario.
4th Sep 2016, 3:48 AM
arvindh
arvindh - avatar