Python function problem

Python function problem


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

class student():
… def__init__(self, id, age, sex)
… = id
… self.age = age
… = 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.


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): = id
    self.age = age = sex


Oh wt a careless mistake, thx for notifying me.