[Tutor] Still stuck - but a bit further on.

Steven D'Aprano steve at pearwood.info
Sun Aug 28 16:18:38 CEST 2011

Lisi wrote:

> Type the Name - leave blank to finishLisi

You have no space in the name. It is "Lisi".

> Type the Street, Town, Phone. Leave blank to finishth, rc, 123457
> Type the Name - leave blank to finish
> Which name to display?(blank to finish) Lisi

Here you have a space at the start of the name: " Lisi".

>  Lisi
> Traceback (most recent call last):
>   File "/usr/local/bin/AddressBook", line 17, in <module>
>     print name, AddressBook[name]
> KeyError: ' Lisi'

Sure enough, no Lisi-with-a-space.

> I have tried various other words besides Lisi, each one less probable than its 
> predecessor.  I am getting nowhere.  The error may well be somewhere else 
> again, but I can't see where. :-(

For further debugging, print AddressBook and see what is in it.


More information about the Tutor mailing list