Answered step by step
Verified Expert Solution
Question
1 Approved Answer
The above code is the correct code for Q1. Please help with Q3 which is described above. Question 3 (4 points.: Purpose: To practice iterating
The above code is the correct code for Q1. Please help with Q3 which is described above.
Question 3 (4 points.: Purpose: To practice iterating over nested compound data and accessing different dictionary fields Degree of Difficulty: Easy. Write a function called pokemon in.continent O which takes as parameter(s): A dictionary in the format of the pokemon database as described in 01 The name of a continent, as a string The function should construct and return a list containing the names of all of the pokemon that can be found on the given continent. For example, for the input file you were given, if the continent is "Africa", the resulting list should be (though not necessarily in this order): ['gyarados', 'nidorina 'magmar', 'jigglypuff' machoke' machamp dragonair', 'slowbro ', 'machop 'venomoth', tentacruel''parasect', omanytepoliwrathmuk'hitmonlee'vaporeon'tangela' gengar 'nidoranmale', 'venusaur','onix', 'nidoking', 'golem', 'aerodactyl', tauros', 'metapod', 'electrode', 'lapras', 'psyduck', 'blastoise' 'nidoqueen', 'alakazam', 'cubone', 'magikarp', 'kabutops', 'kakuna, 'poliwag', 'marowak', 'rhydon ', 'kangaskhan', 'zubat', 'dodrio ', 'persian', 'pikachu', meowth' , 'drowzee', 'gastly' Also, note that this function must not change the pokemon database in any way. bulbasaur,grass,South America ivysaur.grass.Asia.Antarctica venusaur.grass.Africa,South America charmander.fire.North America,Oceania charmeleon,fire.South America charizard,fire,Oceania war e ,water,Antarctica blastoise.water.Africa,South. America caterpie,bug,0ceania metapod.bug.Asia.Af.rica.Europe, outh. America butterfree,bug,Antarctica,Oceania,South America weedle,bug,Europe,South America,Asia kakuna,bug,South America,Oceania,Africa,North America beedrill,bug,North America, Asia,Oceania,Antarctica pidgey,flying,Antarctica, Europe,Oceania, South America Ridgeotto.fling.Europe,..sia pidgeot.flying.Europe,Oceania,Asia rattata.normal,South. America, Europe, Antarctica raticate,normal,Oceania spearow.flying,South. America,North America, Antarctica, Europe ekans,poison,Europe,0ceania,North America, Asia arbok,poison,South America pikachu,electric,North America,Oceania,Africa raichu,electric,North America sandshrew,around,Asia,North America, South America sandslash,around,Asia,South America,North America nidoranfemale,poison,Asia def read_pokedata(fname): iparam fname: a string indicating the location of pokemon data return: a database that stores all data with open(fname) as f: for rec in f.readlines() rec rec.strip().split(",") key rec[0] d [key] rec[1:] returnd print(read_pokedata("pokemonLocations.txt")) Question 3 (4 points.: Purpose: To practice iterating over nested compound data and accessing different dictionary fields Degree of Difficulty: Easy. Write a function called pokemon in.continent O which takes as parameter(s): A dictionary in the format of the pokemon database as described in 01 The name of a continent, as a string The function should construct and return a list containing the names of all of the pokemon that can be found on the given continent. For example, for the input file you were given, if the continent is "Africa", the resulting list should be (though not necessarily in this order): ['gyarados', 'nidorina 'magmar', 'jigglypuff' machoke' machamp dragonair', 'slowbro ', 'machop 'venomoth', tentacruel''parasect', omanytepoliwrathmuk'hitmonlee'vaporeon'tangela' gengar 'nidoranmale', 'venusaur','onix', 'nidoking', 'golem', 'aerodactyl', tauros', 'metapod', 'electrode', 'lapras', 'psyduck', 'blastoise' 'nidoqueen', 'alakazam', 'cubone', 'magikarp', 'kabutops', 'kakuna, 'poliwag', 'marowak', 'rhydon ', 'kangaskhan', 'zubat', 'dodrio ', 'persian', 'pikachu', meowth' , 'drowzee', 'gastly' Also, note that this function must not change the pokemon database in any way. bulbasaur,grass,South America ivysaur.grass.Asia.Antarctica venusaur.grass.Africa,South America charmander.fire.North America,Oceania charmeleon,fire.South America charizard,fire,Oceania war e ,water,Antarctica blastoise.water.Africa,South. America caterpie,bug,0ceania metapod.bug.Asia.Af.rica.Europe, outh. America butterfree,bug,Antarctica,Oceania,South America weedle,bug,Europe,South America,Asia kakuna,bug,South America,Oceania,Africa,North America beedrill,bug,North America, Asia,Oceania,Antarctica pidgey,flying,Antarctica, Europe,Oceania, South America Ridgeotto.fling.Europe,..sia pidgeot.flying.Europe,Oceania,Asia rattata.normal,South. America, Europe, Antarctica raticate,normal,Oceania spearow.flying,South. America,North America, Antarctica, Europe ekans,poison,Europe,0ceania,North America, Asia arbok,poison,South America pikachu,electric,North America,Oceania,Africa raichu,electric,North America sandshrew,around,Asia,North America, South America sandslash,around,Asia,South America,North America nidoranfemale,poison,Asia def read_pokedata(fname): iparam fname: a string indicating the location of pokemon data return: a database that stores all data with open(fname) as f: for rec in f.readlines() rec rec.strip().split(",") key rec[0] d [key] rec[1:] returnd print(read_pokedata("pokemonLocations.txt"))Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started