# Python function problem

**URL:** <https://forum.freecodecamp.org/t/python-function-problem/166009>\
**Category:** General\
**Created:** [December 30, 2017, 6:34am UTC](https://forum.freecodecamp.org/t/python-function-problem/166009 "2017-12-30T06:34:31Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![hahhhhha](https://avatars.discourse-cdn.com/v4/letter/h/b5a626/32.png) [@hahhhhha](https://forum.freecodecamp.org/u/hahhhhha)\
**Post date:** [December 30, 2017, 6:34am UTC](https://forum.freecodecamp.org/t/python-function-problem/166009/1 "2017-12-30T06:34:31Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![kevcomedia](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/kevcomedia/32/125737_2.png) [@kevcomedia](https://forum.freecodecamp.org/u/kevcomedia)\
**Post date:** [December 30, 2017, 6:40am UTC](https://forum.freecodecamp.org/t/python-function-problem/166009/2 "2017-12-30T06:40:40Z")

</div>

According to the docs, it should be

```auto
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

```

---

<div class="post-metadata">

**Author:** ![hahhhhha](https://avatars.discourse-cdn.com/v4/letter/h/b5a626/32.png) [@hahhhhha](https://forum.freecodecamp.org/u/hahhhhha)\
**Post date:** [December 30, 2017, 7:09am UTC](https://forum.freecodecamp.org/t/python-function-problem/166009/3 "2017-12-30T07:09:08Z")

</div>

Oh wt a careless mistake, thx for notifying me.

---

<div class="post-metadata">

**Author:** ![ILM](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/ilm/32/363239_2.png) [@ILM](https://forum.freecodecamp.org/u/ILM)\
**Post date:** [January 16, 2021, 5:12pm UTC](https://forum.freecodecamp.org/t/python-function-problem/166009/4 "2021-01-16T17:12:52Z")

</div>


