[Tutor] python dictionaries

Adam Bark adam.jtm30 at gmail.com
Sat Jan 6 01:02:22 CET 2007


On 05/01/07, Raven Of Night Raven Of Night <raistlen117 at msn.com> wrote:
>
> Hi, there was this two step program I was working on but i can only
> complete
> the first step.
>
> - - Write a Who's Your Daddy? program that lets the user enter the name of
> the male and produces the name of his father. Allow the user to add,
> replace, and delete father son pairs. The program should also allow the
> user
> to get a list of all son, fathers, or father son pairs.
>
> I made a dictionary:
> family = { "Wane Wilright" : "Dan Wilright",
>            "Michal Zheng" : "Tsu Zheng",
>            "Art Core" : "Vandalee Core",
>            "John Wane" : "Calvin Wane" }
>
> and was able to complete the rest of the program.
>
>
> Then I was asked to improve the program:
> - - Improve the Who's Your Daddy program by adding a choice that lets the
> user enter a name and get back a grandfather. Your program should still
> use
> one dictionary of son-father pairs. Make sure to include several
> generatios
> in your dictionary so that a match can be found.
>
> I don't understand, dictionarys only allow two elements so how can you
> include several generations in the dictinoary... could you perhaps put a
> dictinoary inside a dictionary? I don't understand how you would do the
> second part.


Hopefully this will make sense to you as I don't want to give the whole game
away.
A grandfather is just a father's father. If you don't get it still then I'll
make it a bit
more obvious.
HTH,
Adam.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20070106/df0a537b/attachment.html 


More information about the Tutor mailing list