Saturday, 22 January 2022

Python-Slip13a- Write a Python program to input a positive integer. Display correct message for correct and incorrect input. (Use Exception Handling)

  Write a Python program to input a positive integer. Display correct message for correct and incorrect input. (Use Exception Handling)  

while True:

    try:

        a = int(input("Input a number: "))

        if a >= 0:

                                raise ValueError("Positive Number- Correct Input Number")

        else:

                                raise ValueError("Negative Number-InCorrect Input Number")

 

    except ValueError as e:

        print(e)