Extend, Don’t Replace, the Constructor

Medium ⏱ 12 min 53% acceptance ★★★★★ 4.6
Employee stores name and salary. Subclass Manager additionally stores a reports list — its __init__(self, name, salary, reports) must call super().__init__(name, salary) rather than duplicating the assignments, then add team_size() returning len(reports).

Examples

Example 1
Input
Manager('Meera', 180000, ['a', 'b']).team_size()
Output
2
Explanation

Base init handled name/salary; the subclass added its own state.

Constraints

  • super().__init__ is mandatory.
  • No re-assignment of name/salary in Manager.

Topics

OOPsuper()

Companies

MicrosoftAdobeSalesforce

Hints

Hint 1

super() needs no arguments in Python 3.

Hint 2

Add the new attribute after the super call.

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