'error "No value for argument 'change' in unbound method call" for ''x.'' in final line. __init__ method not used
class a:
app = [2,3,5,21,24,28,35]
web = [1,9,22,46]
x = min(app,web);y = max(app,web)
a = len(x)
w = len(y)
c=0;d=0
def till_xbig(self,i ,j ,change):
while self.x[i] < self.y[j] :
self.c+=1
if i<self.a-1 and self.c <self.a:
i+=1
else:
break
change += 1
self.till_ybig(i,j,change)
def till_ybig(self,i,j,change):
while self.y[j] < self.x[i] :
self.d+=1
if j<self.w-1 and self.d<self.w:
j+=1
else:
break
change += 1
if i == self.a-1 and j == self.w-1: return change
self.till_xbig(i,j,change)
x = a
print(x.till_xbig(0,0,0))
**i have assigned class instance to x but still i am getting this "method unbound call" error why is "self" taking up first 0 and the reason why change is not receiving that third 0 as arguement. how to avoid such mistake? **
Solution 1:[1]
Where x = a
means assigning x
as a
class.
In your case, should use x = a()
. It assigns x
as a a
instance.
>>> x = a
>>> x
>>> <class '__main__.a'>
>>> x = a()
>>> x
>>> <__main__.a object at 0x00000215D6FBEF20>
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Leon |