HackerRank- Python Nested Lists




Given the names and grades for each student in a Physics class of N students, store them in a nested list and print the name(s) of any student(s) having the second lowest grade.



  1. marksheet=[]
  2. scorelist=[]
  3. if __name__ == '__main__':
  4. for _ in range(int(input())):
  5. name = input()
  6. score = float(input())
  7. marksheet+=[[name,score]]
  8. scorelist+=[score]
  9. b=sorted(list(set(scorelist)))[1]
  10. for a,c in sorted(marksheet):
  11. if c==b:
  12. print(a)




codesadda.com

Codesadda.com is your home of programming solutions, tutorials, video tutorials and much more. Sign Up for our weekly newsletter to get update about new content.

Like us on Facebook | Connect with us on LinkedIn | Subscribe our Channel on Youtube