How to process tuples
<p>So I have made the following in python to process my highscores.txt file. I couldn't work out how to process tuples, and so I have basically cheated to try and process it. However I am now looking to learn the correct way of doing it. I am also looking to order the lines in the file by biggest score to smallest so that I can print them out. Any help would be greatly appreciated      </p>

<p>def readHighscores():</p>

<pre><code>    inFile = open("highscores.txt", 'r')
    values = []
    names = []
    for line in inFile:
        line = line.translate(None, " ()'")
        name, value = line.split(',')
        value = value.translate(None, "\n")
        print value
        values.append(value)
        names.append(name)
    inFile.close()

    return values, names

def checkHighscore(value):
    values, names = readHighscores()
    for elem in values:
        if int(value) &gt; int(elem):
            return True
    return False

def setHighscores(value, person):
    values, persons = readHighscores()

    for idx, elem in enumerate(values):
        if value &gt; elem:
            continue
        values.insert(idx, str(value))
        persons.insert(idx, person)
        values.pop()
        persons.pop()
        break

    outfile = open("highscores.txt","w")

    i=0
    for i in range(0,len(values)):
        mystring = persons[i],values[i]
        s = str(mystring) + '\n'
        outfile.write(s,)
    outfile.close()
    outfile = open('highscores.txt', 'r')
    print outfile.read()
    outfile.close()
</code></pre>
