There are currently no frequently asked questions associated with this exercise – that’s where you come in! You can contribute to this section by offering your own questions, answers, or clarifications on this exercise. Ask or answer a question by clicking reply () below.
If you’ve had an “aha” moment about the concepts, formatting, syntax, or anything else with this exercise, consider sharing those insights! Teaching others and answering their questions is one of the best ways to learn and stay sharp.
Join the Discussion. Help a fellow learner on their journey.
Ask or answer a question about this exercise by clicking reply () below!
You can also find further discussion and get answers to your questions over in Language Help.
Agree with a comment or answer? Like () to up-vote the contribution!
It all depends on how you define the __add__ method. Remember that for an example like m1 + e1 you can equate it to calling the .__add__ the method of the m1 object with the right-hand operand as the argument: m1.__add__(e1). So what does your method do when it is called?
Without a return all you have are side effects of mutating an existing attribute of m1. If you defined this method with a return of self or a similar meeting object then you could consider assigning the output.
In this example a better method to use might be += (associated with the __.iadd__ method) as it’s really an in-place alternation which is more consistent behaviour with other Python types.
Short version: the second does not work because .__add__ does not return anything so there’s nothing to assign.
I have a question, under the class Meeting, inside the “def__add__(self, employee)” method we have written:
def add(self, employee):
print(“ID {} added.”.format(employee.id))
How can we access the “id” attribute that is inside the class Employee, the “id” attribute is encapsulated inside the Employee class…?
Below is the original code:
class Employee():
new_id = 1
def init(self):
self.id = Employee.new_id
Employee.new_id += 1
I printed the m1.attendees list and as was expected [1, 2, 3] was printed. But first I wrote the reps method otherwise the output will be a list of Employee objects and their memory direction. So I just want to confirm if the m1.attendees list is conformed by Employee objects, but when printing the list the output call the repr method on Employee class?
Hi, I was wondering how “case-sensitiveness” works in this exercise. To my knowledge Python is case-sensitive, but here class Employee and variable employee of add() method are used interchangibly. Has anyone got an insight on this?
Hello, it is because you don’t return anything in the add method. So when you try m1 + e1 + e2, it says that you are trying to add NoneType and Employee. So what you need to do is return the meeting itself.
This way every time you add an employee like this m1 + e1 + e2 + e3 + e4 it will do the first operation first return the meeting and proceed to add the next