Write a Python program to input a number, if it is not a number generate an error message


Introduction

Write a Python program to input a number, if it is not a number generate an error message. I have used python 3.7 compiler for debugging purpose.


techstudy.org

HP 15 Core i3 7th gen Laptop(4GB, 1TB HDD, Windows 10) | Rs. 31,490

  1. while True:
  2. try:
  3. a = int(input("Input a number: "))
  4. break
  5. except ValueError:
  6. print("\nThis is not a number. Try again...")
  7. print()

Result

python language techstudy.org

     





Related Topics




Popular Posts