How do I return an exception?
<p>I wrote a function that needs to do 3 checks and if one of the tests fails it should return an exception of type of LookupError, but it doesn't work.
(*verify_checksum is another function)</p>

<pre><code>def check_datagram(datagram, src_comp, dst_app):
    try:
        src_comp==datagram[0:16]
    except LookupError:
        return "Mismatch in src_comp"
    try:
        dst_app==datagram[40:48]
    except LookupError:
        return "Mismatch in dst_app"
    try:
        verify_checksum(datagram)
    except False:
        return "Wrong checksum"
    return True
</code></pre>

<p>For example:</p>

<p>Input:</p>

<pre><code>check_datagram("1111000000001111000011111111000001010101101010101111111111111111000000001111111100000000","0000111100001111", "11110000")
</code></pre>

<p>Expected output:</p>

<pre><code>"Mismatch in dst_app"
</code></pre>
