Skip to content

Instantly share code, notes, and snippets.

@IndhumathyChelliah
Created July 2, 2020 06:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save IndhumathyChelliah/4ed01bdf7e28f8cd7eb2ff2fd0fb484e to your computer and use it in GitHub Desktop.
Save IndhumathyChelliah/4ed01bdf7e28f8cd7eb2ff2fd0fb484e to your computer and use it in GitHub Desktop.
class Student:
def __init__(self,name,rollno,age):
self.name=name
self.rollno=rollno
self.age=age
def __str__(self):
return "{}-{}-{}".format(self.name,self.rollno,self.age)
s1=Student("karthi",12,7)
s2=Student("Sarvesh",15,3)
#trying to add two class objects,it will raise TypeError.Because compiler doesn't know how to add objects s1 and s2
print (s1+s2) #Output:TypeError: unsupported operand type(s) for +: 'Student' and 'Student'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment