0
Trying to make a phonebook via hashtable but ran into a problem...[FIXED]
I can make the first entry work, but all following entries won't register. I'm new to coding and have been stuck here for a few days so any help world be greatly appreciated. https://code.sololearn.com/cnySF8CwKNHU/?ref=app
6 odpowiedzi
+ 4
def get(self, name):
i = 0
while i < len(self.book):
if self.book[i].name == name:
return self.book[i].number
i += 1
return 'not found'
or
def get(self, name):
for i in self.book:
if i.name == name:
return i.number
return 'not found'
0
i += 1 to the loop :)
0
Thank you for the reply Markus Kaleton, I've updated it but it still doesn't work. Did I put it in the wrong place?
https://code.sololearn.com/cnySF8CwKNHU/?ref=app
0
evilbluekoala put it into the else statement. or you could use for loop to iterate over the list if it checks out. I'll fix ur code and post it here, just a sec
0
Markus Kaleton Thanks so much! It finally makes sense ×D.