Python namedtuple of collections module

Python namedtuple of collections module

Instructor-svgAl-Mamun Sarkar
Mar 26 , 2020

Python namedtuple of collections module. The following code shows how to solve the HackerRank Collections.namedtuple() Python collections problem.

Code:

from collections import namedtuple

(n, categories) = (int(input()), input().split())
Grade = namedtuple('Grade', categories)

marks = [int(Grade._make(input().split()).MARKS) for _ in range(n)]
print((sum(marks) / len(marks)))

 

 

  • Share On:
  • fb
  • twitter
  • pinterest
  • instagram