We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Collections.namedtuple()
Collections.namedtuple()
Sort by
recency
|
1081 Discussions
|
Please Login in order to post a comment
Enter your code here. Read input from STDIN. Print output to STDOUT
from collections import namedtuple n=input() student=namedtuple('student',input().split()) Students=[student(*input().split()) for _ in range(int(n))] print(round(sum(int(i.MARKS) for i in Students)/int(n),2))
Here is HackerRank Collections.namedtuples() in python solution - https://programmingoneonone.com/hackerrank-collections-namedtuple-solution-in-python.html
Collections.namedtuple() is a factory function in Python provided by the collections module that allows you to create simple, immutable classes for storing data — similar to a lightweight class, but with less boilerplate. Gold 365 Site
You can actually forget about namedtuple and just do it old-fashined way ;) Could be shorter ~>_<~