Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

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

# (4 points) Iteration order testing 3 from unittest import TestCase 4 import random 6 tc TestCase() ht = OrderedHashtable(1000) 91[str(i) for i in range (e, 1800)] 10 random.shuffle(1) 12 for x in 1: 13 ht[x] - X 15 for inrange(50): 16 18 19 20 idx to de1 random .randrange(len(1)) val_to_del-l[idx_to del] del ht[val_to_del] del 1[idx_to_del] if random.randrange (2) 1.append (val_to_del) ht[val_to_del]val_to_del 23 24 for x, y in zip(l, ht): 25 tc.assertEqual(x, y) AttributeError Traceback (most recent call last) in () 16 17 18 idx-to-del val_to_del randon. randrange (len(1)) 1[idx_to_del] = - del ht[val_to_del] 19 del 1idx to dell 20 if random.randrange(2) 0 in delitem (self, key) last_node tempnode tempnode - tempnode.next if self.entries[tempnode.index][e]key: -64 65 self.count 1 AttributeError NoneType' object has no attribute 'index

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...