Whats the difference with "print" or whitout, only the string. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Whats the difference with "print" or whitout, only the string.

1. >>>Print 'hello world' Or 2. >>> 'hello world'

19th Oct 2019, 4:35 PM
SE MA GA
SE MA GA - avatar
2 Answers
+ 1
Thank so much.
19th Oct 2019, 4:48 PM
SE MA GA
SE MA GA - avatar
0
In console >>> will print the representation format of a value repr(value), where print function will print the string representation of a value str(value). >>>x output is same than: >>>print(repr(x)) With builtin datatypes repr and str does not have much differences, but with strings, repr will give the string with extra quotes. repr("Hello") -> "\'Hello\'" str("Hello") -> "Hello" repr(25) -> "25" str(25) -> "25" Also >>> will ignore None types. >>> None (no output) >>> print(None) None
19th Oct 2019, 7:24 PM
Seb TheS
Seb TheS - avatar