PYTHON 3. Im getting this error when i run my code. any help on how to fix it ?
ID: 3910129 • Letter: P
Question
PYTHON 3. Im getting this error when i run my code. any help on how to fix it ?
here's my code where the problem is:
def __delitem__(self, key):
index = None
hashindex = hash(key) % len(self.indices)
tempnode= self.indices[hashindex]
if self.entries[tempnode.index][0] == key:
self.count -= 1
del self.entries[tempnode.index]
index = tempnode.index
if tempnode.next is not None:
self.indices[hashindex] = tempnode.next
else:
self.indices[hashindex] = None
else:
while tempnode is not None:
last_node = tempnode
tempnode = tempnode.next
if self.entries[tempnode.index][0] == key:
self.count -= 1
del self.entries[tempnode.index]
index = tempnode.index
last_node.next = tempnode.next
break
else:
raise KeyError
for bucket in self.indices:
tempnode = bucket
while tempnode is not None:
if tempnode.index > index:
tempnode.index -= 1
tempnode = tempnode.next
Explanation / Answer
change to line of code at 9:
l = [(i for i in range(0,1000)]
while accessing l[idx__to_del], idx__to_del must be int
if you still getting error, please give me comment...
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.