17.8. ExercisesΒΆ
-
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.
-
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 variablesr
,d
, andp
respectively. Do not hardcode. Note: Be aware that not every trainer has caught a ditto.
-
Below, we have provided a nested list called
big_list
. Use nested iteration to create a dictionary,word_counts
, that contains all the words inbig_list
as keys, and the number of times they occur as values.
-
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
.