Class - error return

Peter Otten __peter__ at web.de
Tue Sep 6 05:23:58 EDT 2016


Smith wrote:

> you can help me ?

Yes ;) But you might consider posting on python-tutor instead of python-
list.

> I can not understand where is the error in this script.

It's always a good idea to state both what you expect and what you get 
instead explicitly, in plain english.

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

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

That might pass as the "what you get" part; I suppose you expect it to print

Visitor: 8, Contacts: 9

If so look at

>      ...:     def __str__(self):
>      ...:         return "Visitor: %i, Contacts: %i %
> (self.visits,self.contacts)"

once more. Where are the quotes? Where should the be?






More information about the Python-list mailing list