+ 3

About the print statement

do we have 2 methods for print statements 1)print("heloo world") 2)print('heloo world') is both corect ????

4th Jun 2018, 7:40 AM
muthu sabarish
muthu sabarish - avatar
12 ответов
+ 7
Both are correct. The only difference is that you cannot use " inside double quotes and ' inside single quotes.
4th Jun 2018, 8:58 AM
Harsh
Harsh - avatar
+ 5
Yes! Both are correct!
4th Jun 2018, 7:47 AM
Abhishek Tandon
Abhishek Tandon - avatar
+ 2
Both are correct.
4th Jun 2018, 4:59 PM
Mitali
Mitali - avatar
+ 1
Note: print() is a function, not a statement. (In Python3 at least.)
4th Jun 2018, 9:56 AM
Pedro Demingos
Pedro Demingos - avatar
+ 1
u can use " inside a double quote by using \ before" and same for '
4th Jun 2018, 2:44 PM
kumar keshav
+ 1
and there is println too
6th Jun 2018, 6:03 PM
Saifur Rahman
0
yes, because python makes no difference
4th Jun 2018, 3:40 PM
Marco Zanrosso
0
1) you use " to mark your string 2)you use ' to mark your string
4th Jun 2018, 6:37 PM
Tim
Tim - avatar
0
yes , you can use both " as well as '
5th Jun 2018, 10:58 AM
Aditya
Aditya - avatar
0
yes both are correct, python doesn't differentiates between the two, unlike in Java, where ' ' is used for char and " " is used for string. But still for understanding convince, you can use it for char and string differently.
7th Jun 2018, 12:59 AM
Mohd. Mudassir Ansari
Mohd. Mudassir Ansari - avatar
0
Both of them are correct. Some use cases are as follows. Suppose you want to print the following: Python's syntax are easy to understand then you use: print("Python's syntax are easy to understand") if you put the string in single quotes, it will throw an error. Again, if you want to print I have a dog named "Tommy" you have to put that string in single quotes: print('I have a dog named "Tommy"') Other than that you can use any. But usually people prefer single quotes to wrap single word string and double quotes for long strings. Use anyone that you are comfortable with.
22nd Jun 2018, 6:04 AM
Anuj Kumar Nath
Anuj Kumar Nath - avatar