Input and Exception Tips
Learn how to take input from users and handle exceptions in a Pythonic way.
We'll cover the following...
Strip user input
Many developers claim to know how to read user input from the console.
But there’s a twist: when asked to enter something, a user may add extra spaces before or after the requested information, intentionally or otherwise. An evil user may insert additional spaces in the middle, too, but handling that kind of user is beyond the scope of this course.
If we use the input()
function to request a number, we will further call int()
or float()
, both of which are trained to discard ...