Class .program not running

This is a sample O O P project.(NOT WORKING PROPERLY)

class Student:   #Common base class for all students.
    studentcount = 0    #class variable.

    def __init__(self, rollno, name, age):   #class constructor.
        Student.studentcount = +1

    def displayCount(self):
         print("Total students:",Student.studentcount)

    def displayStudent(self):
        print("Rollno :", self.rollno)
        print("Age:", self.age)

    st1=Student(1001," Mahi", 24)
    st2=Student(1002,"Mohan", 25)

    st1.displayStudent( )
    print("Total number of students:", Student.studentcount )

can anyone point out the error.

I can’t see any error. I think something wrong in class construction .
Following is the error message
“C:\Users\Administrator\PycharmProjects\O O P Class & Objects\venv\Scripts\python.exe” “C:/Users/Administrator/PycharmProjects/O O P Class & Objects/”
Traceback (most recent call last):
File “C:/Users/Administrator/PycharmProjects/O O P Class & Objects/”, line 3, in
class Student:
File “C:/Users/Administrator/PycharmProjects/O O P Class & Objects/”, line 20, in Student
st1=Student(1001," Mahi", 24)
NameError: name ‘Student’ is not defined

Process finished with exit code 1

Thank you. Followed your hints. Now it is working properly. Thank you once again

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.