以下是我对解决方案的尝试。结果需要按字典顺序排序,我这样做了,但我不明白为什么我在 #Code 之后提到的测试用例不起作用。
#代码
N=int(input("enter number of students in the range of 2 to 5"))
physics_students=[]
#creating a list of student names with their grades
for i in range(N):
name = input()
score = float(input())
physics_students.append([name,score])
physics_students.sort()
#Removing the lowest grade
grades_list=[]
for i in range(N):
grades_list.append(physics_students[i][1])
grades_list.sort()
grades_list.remove(min(grades_list))
#finding out the names of students with second lowest grade
for i in range(N):
if physics_students[i][1]==grades_list[0]:
print("name",physics_students[i][0])
未通过的测试用例如下:
测试用例 1:4 abhay -50 sri -50 rakesh -50 kishore 51
测试用例 2:5 ram 20 ramesh 20suresh 19 venkat 19 jaydeep 21
慕斯王
肥皂起泡泡
相关分类