So I made this class that outputs '{0}' when x=0 or '{1}' for every other value of x.
class offset(str):
def __init__(self,x):
self.x=x
def__repr__(self):
return repr(str({int(bool(self.x))}))
def end(self,end_of_loop):
#ignore this def it works fine
if self.x==end_of_loop:
return '{2}'
else:
return self
I want to do this:
offset(1).format('first', 'next')
but it will only return the number I give for x as a string. What am I doing wrong?