Employee Records with namedtuple

Medium ⏱ 12 min 59% acceptance ★★★★☆ 4.4
Using collections.namedtuple, define an Employee type with fields name, department, salary. Implement highest_paid(employee_tuples), which accepts a list of plain (name, department, salary) tuples, converts each into an Employee namedtuple, and returns the Employee with the highest salary — comparing via attribute access (.salary), not index access.

Examples

Example 1
Input
highest_paid([('Meera','Analytics',180000), ('Rohit','Analytics',95000)])
Output
Employee(name='Meera', department='Analytics', salary=180000)
Explanation

Meera has the higher salary of the two.

Constraints

  • employee_tuples is non-empty.
  • Must compare using attribute access, e.g. emp.salary.

Topics

Tuplescollections.namedtuple

Companies

MetaLinkedInInfosys

Hints

Hint 1

Employee = namedtuple("Employee", ["name", "department", "salary"]).

Hint 2

Employee(*t) unpacks a plain tuple t into a namedtuple instance.

Loading the Python runtime… Run executes your code and shows printed output; Submit checks your function against this problem's examples.