Python function problem

Python function problem
0

#1

I’m self-learning python and got a problem with a function.

class student():
… def__init__(self, id, age, sex)
… self.id = id
… self.age = age
… self.sex = sex

Traceback (most recent call last):
File “”, line 1, in
File “”, line 2, in student
NameError: name ‘def__init__’ is not defined

The program misinterprets it as a name. Do I need to import a module to activate the function? How can I debug this?
This may be a silly question but I really dun know why this is happening.


#2

According to the docs, it should be

class student:
  # notice the space after def and the colon at the end
  def __init__(self, id, age, sex):
    self.id = id
    self.age = age
    self.sex = sex

#3

Oh wt a careless mistake, thx for notifying me.