Reputation: 370
I am recieving this error multiple times within my code. I it occurring when I am using:
pos -= 1
The error of course is: TypeError: unsupported operand type(s) for -=: 'instance' and 'int'
Any help is appriciated!
def DELETE(pos, lst) :
temp = FIRST(lst)
# move to just before pos
if pos == 0 :
lst.head = temp.nxt
elif pos == END(lst) :
if temp.nxt == None :
lst = MAKENULL()
else :
while (temp.nxt).nxt :
temp = temp.nxt
temp.nxt = None
else :
while pos - 1 > 0 :
temp = temp.nxt
pos -= 1
first = temp
second = temp.nxt
first.nxt = second.nxt
lst.cur = lst.head
Upvotes: 0
Views: 2544
Reputation: 881785
The error you're getting depends only marginally on the code you show -- it's mostly about what pos
is -- apparently an instance of an old-style Python 2 class not implementing special methods to try to fake being an integer (in particular, __isub__
for in-place subtraction.
Upvotes: 1