Mr. President (Problem 43) - InfyTQ Solution in Python

Mr. President (Problem 43)

InfyTQ Solution in Python


PROBLEM STATEMENT

CSE160-Midterm-2015 Spring

You have a list of dictionaries with the following general structure:
presidents =
[ {'name':'George Washington', 'vp':'John Adams'},
{'name':'John Adams', 'vp':'Thomas Jefferson'},
{'name':'Zachary Taylor', 'vp':'Millard Fillmore'},
{'name':'Dwight D. Eisenhower', 'vp':'Richard Nixon'},
{'name':'Richard Nixon', 'vp':'Spiro Agnew'},
{'name':'Richard Nixon', 'vp':'Gerald Ford'}, ....]

For example, George Washington was a president who had John Adams serve as his Vice President ("vp").
Note that if a president served for more than one term or had multiple vice presidents, there could be multiple dictionaries listed for that president.

promoted_vp_ (presidents) will return the list of all vice presidents that also served as president.
E.g. if presidents consists of only the dictionaries listed above:
It returns the list {'John Adams', 'Richard Nixon'}




SOLUTION
SHARE If you find this useful, please share with your friends and Community.
CODE TOGETHER..GROW TOGETHER.
Newer Posts Newer Posts Older Posts Older Posts

More posts

Comments

Post a Comment

Sponsored Content