Question: Problem 5: Write a function that takes an ID as a parameter, and returns the country associated with that ID. Call this function getCountry. Inside
Problem 5: Write a function that takes an ID as a parameter, and returns the country associated with that ID. Call this function "getCountry". Inside of your function, you should be making use of the countryMembership dictionary that you created earlier (or a list generated from that dictionary's items) in order to solve this problem. Test your function by printing out the result of calling it and passing in the user ID 23. The country returned and printed should be Canada. Problem 6: Using your function (by making calls to it), go through the message data and count up and display how many messages were sent by users from Canada. Also count up and display how many were received by users from Canada Problem 7: Create another dictionary with each country as a key, and as a value for each country key there should be a list of two numbers. The first number is the count of sent messages from that country. The second number is the count of received messages from that country. Print your dictionary. It should take on the following format (this is not real data): United States': [2, 4], Canada': [5, 3], 'Italy [1, 2])
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
