I have made this small piece of code that collects a name and a highscore and puts it into a list into a file. Here is my code:
def main():
pass
fileobj = open('c:\\newfile.txt', 'w')
count = 0
player_names = []
high_scores = []
while count < 5:
player_name = input('Name: ')
high_score = input('High Score: ')
player_names.append(player_name)
high_scores.append(high_score)
fileobj.write(player_name + '\n')
fileobj.write(high_score + '\n')
count = count + 1
fileobj.close()
What I am trying to do is create another script that will read that file and print the list and sort it according to the High score values, I have been reading for like an hour or two on how to do it but cant just get the hang of it. This is what my other script looks like so far:
def main():
pass
f = open('c:\\newfile.txt', 'r')
print f
f.readline()
I get an error on the print f
line, but when I take that out the script runs but nothing is displayed.