Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
error in class
#1
class Student():
    def __init__(self, name, CNE, Level ):
        self.name=name
        self.CNE=CNE
        self.Level=Level
    def student_name(self):
        student_info= "name is :" +  self.name + ",CNE is :" + str(self.CNE) + " and Level is :" + self.Level
        return student_info
Student("mohammad ", 1123456789," PhD Student")
print(Student.student_name())
Error:
Error:
Traceback (most recent call last): File "C:/Users/HP/Desktop/Telegram Desktop/class practice.py", line 10, in <module> print(Student.student_name()) TypeError: student_name() missing 1 required positional argument: 'self' Process finished with exit code 1
Reply


Messages In This Thread
error in class - by non_name092 - Sep-02-2020, 05:07 PM
RE: error in class - by bowlofred - Sep-02-2020, 05:42 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  My class has name error message 357mag 3 2,319 Sep-04-2019, 03:29 PM
Last Post: snippsat
  Class Error OmarSinno 1 3,189 Sep-28-2017, 05:49 AM
Last Post: Mekire
  Error Type: <class 'OSError'> And Error Type: <class 'ValueError'> runnerpaul 1 3,664 Jul-18-2017, 03:08 PM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020