classes

Chris Angelico rosuav at gmail.com
Wed Oct 24 08:39:38 EDT 2012


On Wed, Oct 24, 2012 at 11:11 PM, inshu chauhan <insideshoes at gmail.com> wrote:
> print " Adding twice of %4.2f gives " % (y.addtwice())
>
>
> Error is :
>
> Traceback (most recent call last):
>   File "Z:\learning Python\learn5.py", line 35, in <module>
>     print " Adding twice of %4.2f gives " % (y.addtwice())
> TypeError: addtwice() takes exactly 2 arguments (1 given)
>
> why the prog is having this error with self nd x as arguments ???

The first argument is 'self', which is being passed y, but you also
need to pass it a value to add twice. You're ignoring the argument to
__init__ so I don't know what your purpose is, but possibly you should
be saving that into self somewhere??

ChrisA



More information about the Python-list mailing list