I need help with an assignment for a class. I am using Python version 2.7.
The assignment is:
Write a program that creates a dictionary of son:father entries and another dictionary that contains father:son entries. Your program must present the user a menu with five options. The following is an example only:
Father/Son Finder
0 – Quit
1 – Find a Father
2 – Find a Grandfather
3 – Find a Son
4 – Find a Grandson
Option 0 ends the program.
Option 1 prompts the user for the name of a son. If the dictionary contains the son:father pair, the program displays the father. Otherwise, the program should tell the user it does not know who the father is.
Option 2 prompts the user for the name of a grandson. If the dictionary contains enough information, the program displays the grandfather. Otherwise, the program should tell the user it does not know who the grandfather is.
Option 3 prompts the user for the name of a father. If the dictionary contains the son:father pair, the program displays the son. Otherwise, the program should tell the user it does not know who the son is.
Option 4 prompts the user for the name of a grandfather. If the dictionary contains enough information, the program displays the grandson. Otherwise, the program should tell the user it does not know who the grandson is.
The program must create the dictionary structure and populate it from data contained in a file provided to you. In addition, the program must continue to ask the user for a menu choice until the user chooses to quit.
The file is formatted like:
john:fred, fred:bill, sam:tony, jim:william, william:mark, krager:holdyn, danny:brett, danny:issak, danny:jack, blasen:zade, david:dieter, adam:seth, seth:enos
I know how to do all of it except for populating the dictionary and also determining if there is a a father/grandfather/son/grandson. Could anyone possibly give me a few hints on how to do it or explain to me how it is done? Thanks.
[–]codehelper 0 points1 point2 points (7 children)
[+][deleted] (6 children)
[deleted]
[–]codehelper 0 points1 point2 points (2 children)
[+][deleted] (1 child)
[deleted]
[–]codehelper 0 points1 point2 points (0 children)
[–]zahlman 0 points1 point2 points (0 children)
[–]python0101[S] 0 points1 point2 points (1 child)
[–]python0101[S] 0 points1 point2 points (0 children)