At first I don’t think any of us did. We find out in short order, though, eh?
> is the command prompt. Type or paste there and Enter to execute immediately or in the case of a function, store it in memory.
When we type,
> 3 * 4
we can see the immediate response. What we don’t see is what goes on in the background.
Okay, that’s not Python, but we can witness an example of the behavior in our browser.
Back on Python,
raw_input() (which is Python 2, and deprecated in Python 3) can be thought to operate along the same lines. It’s a function that polls the input buffer and when a character 13 is found, returns the content of the buffer, as a string. This might not be accurate but that’s not really important, It’s the general premise we’re looking at, not the technical details.
Later on you will learn more about exceptions and why they are invaluable and something we never wish to subvert, but rather give full rein and address the concerns that surface. As mentioned above, if the input cannot be cast to a number (integer) it will raise an exception…
Enter any integer: two
Traceback (most recent call last):
File "<pyshell#178>", line 1, in <module>
print (by_three(int(raw_input('Enter any integer: '))))
ValueError: invalid literal for int() with base 10: 'two'
The exception it raised is
'two' is not a valid argument for