This Looks Like a Job For


#1

https://www.codecademy.com/courses/learn-python/lessons/introduction-to-classes/exercises/this-looks-like-a-job-for?action=lesson_resume

I struggle to find a problem in my code, but it keeps throwing this error:
Traceback (most recent call last):
File “python”, line 11, in
File “python”, line 20, in PartTimeEmployee
File “python”, line 17, in full_time_wage
TypeError: calculate_wage() takes exactly 2 arguments (1 given)

I would appreciate it if someone could please help me with this, as I’ve been looking for an error in my code for a long time and I don’t know what the problem is



class Employee(object):
  """Models real-life employees!"""
  def __init__(self, employee_name):
    self.employee_name = employee_name

  def calculate_wage(self, hours):
    self.hours = hours
    return hours * 20.00

# Add your code below!
class PartTimeEmployee(Employee):
  def calculate_wage(self, hours):
    self.hours = hours
    return hours * 12.00
  
  def full_time_wage(self, hours):
    return super(PartTimeEmployee, self).calculate_wage(hours)
  
  milton = PartTimeEmployee("Milton")
  print milton.full_time_wage(10)



#2

Hi @fruitsg

It appears that this part of your code is indented within your class. Why put that part of your code in your class? If we were to create multiple instances of our class, we should keep them outside of our classes.


#3

Oh wow, that was actually the problem. Thanks a bunch. I still need to get used to Python indentation, haha. I appreciate the help.


#4

You’re welcome. :slight_smile:


Extra thing:

It’s good to keep our newly created instances such as:

milton = PartTimeEmployee("Milton")

so we can call them:

print milton.full_time_wage(10)

whenever we want to in any part of our code. It makes things easier. :slight_smile:


#5

Thank for the tip, I’ll definitely keep it in mind :slight_smile:


#7

This topic is solved.