Python Forum
Why Car() takes no arguments
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Why Car() takes no arguments
#1
class Car:

    def __int__(self,make,model,year):
        self.make = make
        self.model = model
        self.year = year

    def get_descriptive_name(self):
        long_name = str(self.year) + ' ' + self.make + ' ' + self.model
        return long_name.title()


my_new_car = Car('audi','a4','2016')
print(my_new_car.get_descriptive_name())
Reply
#2
You have typo on line#3. The function should be __init__
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#3
tq buran
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Checking the number of arguments a function takes Chirumer 3 197 Jul-06-2021, 04:56 PM
Last Post: Chirumer
  Class Takes No Arguments horuscope42 4 1,880 Oct-26-2020, 11:10 PM
Last Post: not_username1234
  Class takes no arguments Nazartfya 2 1,177 Jun-27-2020, 12:45 PM
Last Post: Nazartfya
  random.choice() takes two positional arguments, but three were given. ShakeyPakey 5 3,060 May-31-2020, 03:13 PM
Last Post: deanhystad
  Question() takes no arguments jwrcfv 2 1,133 Apr-02-2020, 06:08 PM
Last Post: jwrcfv
  add() takes 2 positional arguments but 3 were given Man_from_India 3 2,525 Feb-10-2020, 05:08 PM
Last Post: Man_from_India
  Class takes no arguments Myang123 3 6,529 Nov-26-2019, 12:01 PM
Last Post: Davy_Jones_XIV
  This constructor takes no arguments Friend 2 3,320 Jun-26-2019, 02:54 PM
Last Post: Friend
  takes 21 positional arguments but 24 were given sophsoph 5 1,873 Jun-21-2019, 12:53 AM
Last Post: ichabod801
  Why Person() takes no arguments dianefly 3 27,615 Oct-22-2018, 04:15 PM
Last Post: dianefly

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020