'How to write code to catch null exception in python
I have below code, which I want to write in a way so that it catches proper exception when none is passed when argument value is required.
  def MyFunction(MyArg1, MyArg2):
     if not MyArg2:
          raise ?Error?
I think it will be type error but I need the exception to be more explicit
Solution 1:[1]
Maybe try this
if key is None:
    raise TypeError
or
if key is None:
    print("There is no key.")
Solution 2:[2]
This is what I have trieD
    if MyArg2 is None:
    raise TypeError
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source | 
|---|---|
| Solution 1 | Junot | 
| Solution 2 | 
