How to deal with incorrect input data types | Sololearn: Learn to code for FREE!
Nouvelle formation ! Tous les codeurs devraient apprendre l'IA générative !
Essayez une leçon gratuite
0

How to deal with incorrect input data types

I'm trying to make a simple area machine. To make it marginally unbreakable, I want it to keep asking for an input if what's entered is not a number. I need this to happen for both length and width. Thanks! https://code.sololearn.com/c3uYAOoC739Q/?ref=app

17th Oct 2017, 4:31 PM
Sketchy
Sketchy - avatar
1 Réponse
0
try{ ...... }catch(the error that you want to catch ){....} the normal flow of the code when it reach the input and that input isn't float will throw an error , so you can put try and catch block inside the loop . and your code inside the try and when the error happens will catch it and execute the logic inside the catch .
19th Oct 2017, 9:53 PM
amr hassan (3Mo0or)
amr hassan (3Mo0or) - avatar