Advertisement
Guest User

Levée d'exception ValueError

a guest
Feb 18th, 2018
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.24 KB | None | 0 0
  1. #coding:utf-8
  2.  
  3. nb1 = int(input("Choisir numérateur : "))
  4. nb2 = int(input("Choisir dénominateur : "))
  5.  
  6. try:
  7.     if nb2 == 0:
  8.         raise ValueError
  9.  
  10.     print(f"Résultat = {nb1//nb2}")
  11. except ValueError:
  12.     print("Dénominateur incorrect !")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement