Python handling exceptions

By Koni GTA

In my program, I want to take in an input which should be a number.If the user inputs a string, however, the program returns an exception.I want the program set in such a way that the input is converted to int and then if the string is anything other than an int the program prints that “Stop writing please”.Like for example:

   x=input("Enter a number")
        if int(x)=?:         #This line should check whether the integer conversion is possible
        else                #This line should execute if the above conversion couldn't take place
        print("Stop writing stuff")

Source: Stack Overflow


Share it with your friends!

    Fatal error: Uncaught Exception: 12: REST API is deprecated for versions v2.1 and higher (12) thrown in /home/content/19/9652219/html/wp-content/plugins/seo-facebook-comments/facebook/base_facebook.php on line 1273