On 2020-12-27 at 19:55:39 -0300, "Joao S. O. Bueno" firstname.lastname@example.org wrote:
I tried to make clear this should be in addition to that - But yes, I failed to mention in my message that I think such a function would mostly benefit beginners learning around with "input" and "print" - it is painful to suddenly have to tour the students on several other concepts just to get a correct user-inputed number. (OTOH, yes, for code on this level, one normally won't be concerned if the program user will be typing "1.02e2" on the `input` prompt).
OTOH, learning that translating a user-entered string to a floating point number is not as simple as it sounds is a great lesson. Please don't teach beginners that handling user input (let alone floating point arithmetic) is easy and/or foolproof. Start with letting the program fail when the input is invalid, teach them to isolate input validation into its own function(s), and introduce try/except as one method of control flow in a validation function.