new value replaces the current value associated with the key def addselfkeyvalue )ndx self _findpositionkey if ndx is not none if the key was found self _entrylist[ndxvalue value return false else otherwise add new entry entry _mapentrykeyvalue self _entrylist appendentry return true returns the value associated with the key def valueofselfkey )ndx self _findpositionkey assert ndx is not none"invalid map key return self _entrylist[ndxvalue removes the entry associated with the key def removeselfkey )ndx self _findpositionkey assert ndx is not none"invalid map key self _entrylist popndx returns an iterator for traversing the keys in the map def __iter__self )return _mapiteratorself _entrylist helper method used to find the index position of category if the key is not foundnone is returned def _findpositionselfkey )iterate through each entry in the list for in rangelen(selfis the key stored in the ith entryif self _entrylist[ikey =key return when not foundreturn none return none storage class for holding the key/value pairs class _mapentry def __init__selfkeyvalue )self key key self value value many of the methods require search to determine if the map contains given key in this implementationthe standard in operator cannot be used since the list contains mapentry objects and not simply key entries insteadwe have to search the list ourselves and examine the key field of each mapentry object likewisewe routinely have to locate within the list the position containing specific key/value entry since these operations will be needed in several methodswe can create helper method that combines the two searches and use it where needed the findposition(helper method searches the list for the given key if the key is foundthe index of its location is returnedotherwisethe function