Hi,
you can help me ?
I can not understand where is the error in this script.
Use Python3.


In [71]: class Day(object):
    ...:     def __init__(self,visits,contacts):
    ...:         self.visits = visits
    ...:         self.contacts = contacts
    ...:     def __add__(self,other):
    ...:         total_visits = self.visits + other.visits
    ...:         total_contacts = self.contacts + other.contacts
    ...:         return Day(total_visits,total_contacts)
    ...:     def __radd__(self,other):
    ...:         if other == 0:
    ...:             return self
    ...:         else:
    ...:             return self.__add__(other)
    ...:     def __str__(self):
...: return "Visitor: %i, Contacts: %i % (self.visits,self.contacts)"
    ...:
    ...:



In [72]: day1 = Day(8,9)

In [73]: day2 = Day(7,7)

In [74]: print(day1)
Visitor: %i, Contacts: %i % (self.visits,self.contacts)

In [75]: print(day2)
Visitor: %i, Contacts: %i % (self.visits,self.contacts)
--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to