Python Add to dictionary loop -
When I run the loop, this function adds a name and number to "Phonebook", but for some reason No idea but why can not I get it to work? thanks a lot!
phonebook = dict (def) addNumber (name, number): i in phonebook: if i == name: print 'error' and: phonebook [name] = number you actually loop Not exactly required, you only need to check the name against the current key of the code in the code> in the code> in Phonebook: Name: print 'error' else: phonebook [name] = number
Comments
Post a Comment