Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # define Python user-defined exceptions
- class MyError(Exception):
- """Base class for other exceptions"""
- pass
- class KeyNoExist(MyError):
- """Raised when the input value is too small"""
- pass
- class ValueNoExist(MyError):
- pass
- def diction(slownik):
- for key in slownik:
- if (slownik[key] == podaj):
- print(key)
- return True
- elif (key == podaj):
- print(slownik[podaj])
- return True
- return False
- def rekurencja(slownik):
- start = 0
- while start < 3:
- if diction(slownik):
- return True
- else:
- diction(slownik)
- start += 1
- return False
- if not rekurencja(d):
- raise KeyNoExist
- d = dict(weather="clima", earth="terra", rain="chuva")
- podaj = input("Podaj słowo: ").lower()
- if diction(d):
- print("Congratulations! You guessed it correctly.")
- else:
- print("That english word doesn't exist in our dictionary!")
- raise KeyNoExist
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement