Recalling data from a text document on python 3
<p>I have made this script which will save players names followed by their scores. </p>

<p>I am looking to recall this data back into python so it can be sorted into a table in a UI.</p>

<p>Im sure its a simple solution but i can only find how to save to a text document.</p>

<pre><code>    players=int(input("How many payers are there? "))

    with open('playerscores.txt', mode='wt', encoding='utf-8') as myfile:
        for i in range (players):
            username=input('Enter you username: ')
            score=input('Enter your score: ')
            playerinfo= [username,score, '\n']
            myfile.write('\n'.join(playerinfo))
</code></pre>

<p>There are multiple ways to do 
1. you will reopen the your playerscores.txt file read the data from it store it in buffer sort it and write it again .
2. while tacking input store it in buffer sort them and then write on txt file. </p>

<pre><code>players=int(input("How many payers are there? "))
with open('playerscores.txt', mode='wt', encoding='utf-8') as myfile:
    playerinfo = []
    for i in range (players):
        username=input('Enter you username: ')
        score=input('Enter your score: ')
        playerinfo.append([username,score,'\n'])
    playerinfo = sorted(playerinfo, key = lambda x: int(x[1]))
    for i in playerinfo:
    myfile.write('\n'.join(i))
</code></pre>

python python-3.x serialization