Python Program to Build a Number Guessing Game
class SmallValue(Exception): def display(self): print("You Guessing nmuber is small") class LargeValue(Exception): def display(self): print("You Guessing nmuber is large") max=100 while 1: try: num=int(input("Guess a number: ")) if num==max: print("Great! You Guess the nmuber!") break if nummax: raise LargeValue except SmallValue as s: s.display() except LargeValue as l: l.display()
Output: