python switch/case with conditions : <p>if-else statements are cumbersome. I want to construct a switch/case statement in Python. But switch/case statements in Python are geared towards specific cases such as: </p>

<pre><code>def switch(case):
    return {
        "a":fa,
        "b":fb,
    }.get(case, f_default)
</code></pre>

<p>But I want the case to meet certain conditions as in the following:</p>

<pre><code>def descriptor(magnitude):
    return {
        magnitude == 10.0: 'Meteoric',
        magnitude &gt;= 9.0: 'Great',
        magnitude &gt;= 8.0: 'Major',
        magnitude &gt;= 7.0: 'Strong',
        magnitude &gt;= 6.0: 'Moderate',
        magnitude &gt;= 5.0: 'Light',
        magnitude &gt;= 4.0: 'Minor',
        magnitude &gt;= 3.0: 'Very Minor',
        magnitude &lt;= 2.0: 'Micro'
}.get(magnitude, magnitude == True)()
</code></pre>

<p>My thinking is that the return key in the dictionary is anything that is true. which is why I wrote <code>magnitude == True</code>. Can someone give me some guidance, my thoughts are in <code>magnitude == True</code> but without it, there is a KeyValue error as expected.</p>
