Shortest way to run seven if statements in Python
<p>I have an <code>if</code> statements that checks a number and then return a string value accordingly.</p>

<p><strong>code:</strong></p>

<pre><code>def get_weekday(day):
    if day in ['1', 1]:
        return 'Monday'
    elif day in ['2', 2]:
        return 'Tuesday'
    elif day in ['3', 3]:
        return 'Wednesday'
    elif day in ['4', 4]:
        return 'Thursday'
    elif day in ['5', 5]:
        return 'Friday'
    elif day in ['6', 6]:
        return 'Saturday'
    elif day in ['7', 7]:
        return 'Sunday'
    return 'Invalid day selected'
</code></pre>

<p>The question may appear subjective but I think there should be a <strong>pythonic</strong> and better and shorter and cleaner way of writing this.</p>

<p>You could use a <strong><a href="https://docs.python.org/2/tutorial/datastructures.html#dictionaries" rel="nofollow">dictionary</a></strong> aka map and simply put in multiple keys for the same values. </p>

<p>Then you only need to ask that dictionary for the value matching the current <em>day</em> key.</p>

python