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

19th Jul 2018, 9:00 AM
evilbluekoala
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'
19th Jul 2018, 11:36 AM
Mert Yazıcı
Mert Yazıcı - avatar
0
i += 1 to the loop :)
19th Jul 2018, 9:34 AM
Markus Kaleton
Markus Kaleton - avatar
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
19th Jul 2018, 9:50 AM
evilbluekoala
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
19th Jul 2018, 12:17 PM
Markus Kaleton
Markus Kaleton - avatar
19th Jul 2018, 12:40 PM
Markus Kaleton
Markus Kaleton - avatar
0
Markus Kaleton Thanks so much! It finally makes sense ×D.
19th Jul 2018, 12:47 PM
evilbluekoala