Fauna in Chitwan National Park

Published by BijogFc24 in

Create a function that takes a string containing both the name and number of animals and plants that may or may not be found in Chitwan National Park. The function should return an list of tuples where the first element in the tuple is the animal name and the second element in the tuple is a number of that particular animal that is found in Chitwan National Park.

Animals Present in Chitwan National Park

animals = ["muggercrocodile", "one-hornedrhino", "python", "moth", "monitorlizard", "bengaltiger"]

Examples

fauna_number("There are 24 one-hornedrhino,50 python and 20000 mango.") ➞ [("one-hornedrhino", "24"), ("python", "50")]
# Mango not present in animal list.

fauna_number("There are 244 bengaltiger,200 monitorlizard and 5000 apples .") ➞ [("bengaltiger", "244"), ("monitorlizard", "200")]
# Apples not present in animal list.

Notes

  • Input contains name and number of both animals and plants.
  • If there is no match, return an empty list.
Watch a quick demo on how Edabit works.