lambda python function in reversing list
<pre><code>scores = []
with open("scores.txt") as f:
    for line in f:
        name, score = line.split(',')
        score = int(score)
        scores.append((name, score))
        scores.sort(key=lambda s: s[1])
for name, score in scores:
    print(name + ", " + str(score))
</code></pre>

<p>This code can be used to show a txt file looking like this (disordered):</p>

<pre><code>alpha, 3
beta, 1
gamma, 2
</code></pre>

<p>To looking like this:</p>

<pre><code>beta, 1
gamma, 2
alpha, 3
</code></pre>

<p>How can I modify the code so that it instead prints as:</p>

<pre><code>alpha, 3
gamma, 2
beta, 1 
</code></pre>

<p>Just use <code>scores[::-1]</code> instead of <code>scores</code> in the last for-loop. Here's a small illustration of this behaviour:</p>

<pre><code>a=list(range(10))
print(a[::-1])
</code></pre>

python