Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Adding two Objects in Python 3

Name: Anonymous 2011-11-16 23:32

I am defining a class, and one of the methods I want is to return the SUM of two objects which hold int values. My code currently reads -

def get_total(self):
    return self.__num1 + self.__num2

The error I get -

    return self.__num1 + self.__num2
TypeError: unsupported operand type(s) for +: 'Num' and 'Num'


If anyone can help me out I'd appreciate it.

Name: Anonymous 2011-11-17 15:27

>>6
Problem?

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List