> -----Original Message----- > Message: 7 > Date: Fri, 05 Jan 2007 15:43:56 -0800 > From: "Raven Of Night Raven Of Night" <[EMAIL PROTECTED]> > Subject: [Tutor] python dictionaries > To: tutor@python.org > Message-ID: <[EMAIL PROTECTED]> > Content-Type: text/plain; format=flowed > > 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. > > _________________________________________________________________ > The MSN Entertainment Guide to Golden Globes is here. Get all the scoop. > http://tv.msn.com/tv/globes2007/?icid=nctagline2 > > > > ------------------------------ > > Message: 8 > Date: Sat, 6 Jan 2007 00:02:22 +0000 > From: "Adam Bark" <[EMAIL PROTECTED]> > Subject: Re: [Tutor] python dictionaries > To: "Raven Of Night Raven Of Night" <[EMAIL PROTECTED]> > Cc: tutor@python.org > Message-ID: > <[EMAIL PROTECTED]> > Content-Type: text/plain; charset="iso-8859-1" > > On 05/01/07, Raven Of Night Raven Of Night <[EMAIL PROTECTED]> 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/att ac > hment.htm
Think of it this way: My name is Barry. My father's name is Jim. Jim's father's name is Walt (***my grandfather***). How can you use your dictionary to emulate that? Good luck. Regards, Barry [EMAIL PROTECTED] 541-302-1107 ________________________ We who cut mere stones must always be envisioning cathedrals. -Quarry worker's creed _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor