Why is this error?
DavidKobalia

class rectangle:
-def --init--(self, width=1 ,length=1,color): #I can't give default values for arguments
--self.width = width
--self.length = length
--self.color = color
-def perimeter(self):
--return (self.width+self.length)*2

You are viewing a single comment. View All
elonmaks

Hi, @DavidKobalia

#This is correct code:

class rectangle:
def init(self, color, width=1 ,length=1):
self.width = width
self.length = length
self.color = color
def perimeter(self):
return (self.width+self.length)*2

#Explanation:

#firstly non-default argument should not follow default argument , it #means you can't define (a="b",c)

#What you can define:

def example(a, b, c=None, r="w" , d=[], *ae, **ab):
^
|
|
|
So follow only in that order