fork download
  1. try:
  2. n=int(input("Enter the number:"))
  3. result=10/n
  4. except ValueError:
  5. print("invalid input")
  6. except ZeroDivisionError:
  7. print("cannot divide by zero")
  8. else:
  9. print("result:",result)
  10.  
Success #stdin #stdout 0.03s 9728KB
stdin
2
stdout
Enter the number:result: 5.0