Created
August 15, 2020 16:11
-
-
Save mayankdawar/ec4f2accf900fc3d0b6fadf824c21a6e to your computer and use it in GitHub Desktop.
Below, we have provided a species list and a population list. Use zip to combine these lists into one list of tuples called pop_info. From this list, create a new list called endangered that contains the names of species whose populations are below 2500.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
species = ['golden retriever', 'white tailed deer', 'black rhino', 'brown squirrel', 'field mouse', 'orangutan', 'sumatran elephant', 'rainbow trout', 'black bear', 'blue whale', 'water moccasin', 'giant panda', 'green turtle', 'blue jay', 'japanese beetle'] | |
population = [10000, 90000, 1000, 2000000, 500000, 500, 1200, 8000, 12000, 2300, 7500, 100, 1800, 9500, 125000] | |
pop_info = zip(species,population) | |
endangered = [x1 for x1,x2 in pop_info if x2< 2500] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment