Python Forum
errors in code - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/Forum-Python-Coding)
+--- Forum: General Coding Help (https://python-forum.io/Forum-General-Coding-Help)
+--- Thread: errors in code (/Thread-errors-in-code)



errors in code - sylvie1987100 - Jul-19-2019

I'm getting a TypeError. I want to call out my initialised parameters

Code:
class Students:
	def _init_(self, name,age,grade):
		self.name = name
		self.age = age
		self.grade = grade

		
student1 = Students("Bob", 12, "7th")
Error:
Error:
Traceback (most recent call last): File "<pyshell#2>", line 1, in <module> student1 = Students("Bob", 12, "7th") TypeError: this constructor takes no arguments



RE: errors in code - buran - Jul-19-2019

it should be __init__, not _init_, i.e. double vs single underscore on both sides (before/after)


RE: errors in code - ndc85430 - Jul-20-2019

The class name should also be singular - what it defines is the type of a single kind of thing, not a collection of them.


RE: errors in code - sylvie1987100 - Sep-11-2019

I am very grateful