Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 errors in code
I'm getting a TypeError. I want to call out my initialised parameters

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

student1 = Students("Bob", 12, "7th")
Traceback (most recent call last): File "<pyshell#2>", line 1, in <module> student1 = Students("Bob", 12, "7th") TypeError: this constructor takes no arguments
buran wrote Jul-19-2019, 10:54 AM:
Please, use proper tags when post code, traceback, output, etc. This time I have added tags for you.
See BBcode help for more info.
it should be __init__, not _init_, i.e. double vs single underscore on both sides (before/after)
The class name should also be singular - what it defines is the type of a single kind of thing, not a collection of them.
I am very grateful

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  Errors in code coolcassie 2 137 Dec-03-2019, 12:10 AM
Last Post: coolcassie
  Errors trying to run code ziggyztz 3 231 Nov-03-2019, 04:24 AM
Last Post: newbieAuggie2019
  Decorator toy code throws syntax errors kevinxhi 3 975 Sep-04-2017, 03:01 AM
Last Post: kevinxhi

Forum Jump:

Users browsing this thread: 1 Guest(s)