On 2020-03-13 09:46:29 +0100, joseph pareti wrote:
> The program works when I instantiate the class as:
> 
> fiat = PKW("Fiat Marea",50,0)
> 
> but it fails if I say:
> 
> *fiat = PKW("Fiat Marea",50,0,1)*

The __init__ method of PKW has this signature:

>     def __init__(self, bez, ge, ins):

You are calling it with

    self = (the newly created object)
    bez  = "Fiat Marea"
    ge   = 50
    ins  = 0

and an extra Parameter 1, Python doesn't know what to do with that
parameter, so it complains about it:

Traceback (most recent call last):
  File "joepareti54", line 19, in <module>
    fiat = PKW("Fiat Marea",50,0,1)
TypeError: __init__() takes 4 positional arguments but 5 were given

        hp

PS: Please add spaces after commas. «PKW("Fiat Marea", 50, 0, 1)» is
    much easier to read than «PKW("Fiat Marea",50,0,1)».

-- 
   _  | Peter J. Holzer    | Story must make more sense than reality.
|_|_) |                    |
| |   | h...@hjp.at         |    -- Charles Stross, "Creative writing
__/   | http://www.hjp.at/ |       challenge!"

Attachment: signature.asc
Description: PGP signature

-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to