For questions below, use the following nested data structure to answer the questions. social_network = {'bb_dawg$': ('Barry Bowden', 18, ['New York City NY', 'Langley VA'], ['Elisa Yang', 'Andrew Yamins', 'James Butler']), 'yo_jimbo2000': ('James Butler', 21, ['Boston MA'], ['Barry Bowden']), 'e_yan2002': ('Elisa Yan', 20, ['College Park MD', 'Clarksburg MD'], ['Andrew Yamins', 'Barry Bowden']), 'bmansford1990': ('Benard Mansford', 31, ['San Jose CA', 'College Park MD'], []), 'derp1234': ('who cares', 99, ['College Park MD'], []) } Q1) Notice that a removed user ('Andrew Yamins') is still contained in the friends list of a few users. Write a few lines of code to remove him from those friends lists in the social network. Q2) Write a short Python function called find_user_lived that takes a string as input along with the social network data structure; the string should be a city and state and the function should return a list with all the users who have ever lived in that city (order does not matter!)
For questions below, use the following nested data structure to answer the questions.
social_network = {'bb_dawg$': ('Barry Bowden', 18, ['New York City NY', 'Langley VA'], ['Elisa Yang', 'Andrew Yamins', 'James Butler']),
'yo_jimbo2000': ('James Butler', 21, ['Boston MA'], ['Barry Bowden']),
'e_yan2002': ('Elisa Yan', 20, ['College Park MD', 'Clarksburg MD'], ['Andrew Yamins', 'Barry Bowden']),
'bmansford1990': ('Benard Mansford', 31, ['San Jose CA', 'College Park MD'], []),
'derp1234': ('who cares', 99, ['College Park MD'], [])
}
Q1) Notice that a removed user ('Andrew Yamins') is still contained in the friends list of a few users. Write a few lines of code to remove him from those friends lists in the social network.
Q2) Write a short Python function called find_user_lived that takes a string as input along with the social network data structure; the string should be a city and state and the function should return a list with all the users who have ever lived in that city (order does not matter!).
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 4 images