Why Does Python Print Even If I Don't Type Print?
print 'a'; 'b' Will output: 'a' 'b' Simply typing an int or string into the console will cause it to print. 1 Will output: 1 Is there a reason or benefit for this?
Solution 1:
The interactive Python interpreter is a REPL:
a simple, interactive computer programming environment that takes single user inputs (i.e. single expressions), evaluates them, and returns the result to the user
What you are seeing is the return value for each statement. Consider a slightly less simple example where the return value is different from the input:
>>>2 + 3
5
The tight feedback loop provided by a REPL can be especially helpful when exploring a new language or problem domain.
Post a Comment for "Why Does Python Print Even If I Don't Type Print?"