17.8. ExercisesΒΆ

  1. Iterate through the list so that if the character β€˜m’ is in the string, then it should be added to a new list called m_list. Hint: Because this isn’t just a list of lists, think about what type of object you want your data to be stored in. Conditionals may help you.

    Before you keep reading...

    Making great stuff takes time and $$. If you appreciate the book you are reading now and want to keep quality materials free for other students please consider a donation to Runestone Academy. We ask that you consider a $10 donation, but if you can give more thats great, if $10 is too much for your budget we would be happy with whatever you can afford as a show of support.

  1. The nested dictionary, pokemon, shows the number of various Pokemon that each person has caught while playing Pokemon Go. Find the total number of rattatas, dittos, and pidgeys caught and assign to the variables r, d, and p respectively. Do not hardcode. Note: Be aware that not every trainer has caught a ditto.

  1. Below, we have provided a nested list called big_list. Use nested iteration to create a dictionary, word_counts, that contains all the words in big_list as keys, and the number of times they occur as values.

  1. Provided is a dictionary that contains pokemon go player data, where each player reveals the amount of candy each of their pokemon have. If you pooled all the data together, which pokemon has the highest number of candy? Assign that pokemon to the variable most_common_pokemon.

17.8.1. Contributed ExercisesΒΆ