Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

I'm biginner in python

class Student:
    numbr_of_student=0
    def __init__(self,name,age,courses):
        self.name = name
        self.age = age
        self.courses = courses
        Student.numbr_of_student+=1
student_1=Student("achref",11,["math"])
student_2=Student("azzedine",12,["science"])
print(student_1,student_2)

Output:

<__main__.Student object at 0x000001BA4347FD00> <__main__.Student object at 0x000001BA4347FC40>

What is the problem?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

You are printing 2 objects of the "student" class. When you call print, it is showing you the objects.

What you probably want is print the attributes:

print(student_1.name, student_1.age, student_1.courses)

You can also read this to see how to do get all attributes at once: Print all properties of a Python Class

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading