im currently making a program that takes in the names and scores of the student but i dont know how to get the top 3 scores when the scores starts to get the same
ex student 1 is 100 student 2 is 99 student 3 and 4 is 98 i dont know how to print both student 3 and 4 at the same time.
def getStudent():
grades = 50
sgrade = []
names = []
h1 =[]
h2 =[]
h3 =[]
fob = open('Student.txt')
fob_read = fob.readlines()
for line in fob_read:
(name,grade) = line.split()
names.append(name)
sgrade.append(grade)
fob.close()
print(sgrade)
print(name)
if grade > grades:
grades = grade
h1.append(name+grade)
while True:
fob = open("Student.txt",'r')
raw = fob.readlines()
name = raw_input("Student Name: ")
grade = input("Grade:")
if name == "1":
if grade == 1:
break
if grade >= 50:
if grade <= 100:
opw = open("Student.txt",'w')
opw.writelines(raw)
opw.write(name +" ")
opw.write(str(grade))
opw.write('\n')
opw.close()
else:
print("Grade must be 50 - 100 ")
else:
print("Grade must be 50 - 100 ")
getStudent()