Archived
saving changes
This commit is contained in:
+1
-1
@@ -1 +1 @@
|
||||
from .animal_requests import get_all_animals
|
||||
from .animal_requests import get_all_animals, get_single_animal
|
||||
@@ -24,4 +24,19 @@ ANIMALS = [
|
||||
|
||||
|
||||
def get_all_animals():
|
||||
return ANIMALS
|
||||
return ANIMALS
|
||||
|
||||
# Function with a single parameter
|
||||
def get_single_animal(id):
|
||||
# Variable to hold the found animal, if it exists
|
||||
requested_animal = None
|
||||
|
||||
# Iterate the ANIMALS list above. Very similar to the
|
||||
# for..of loops you used in JavaScript.
|
||||
for animal in ANIMALS:
|
||||
# Dictionaries in Python use [] notation to find a key
|
||||
# instead of the dot notation that JavaScript used.
|
||||
if animal["id"] == id:
|
||||
requested_animal = animal
|
||||
|
||||
return requested_animal
|
||||
Reference in New Issue
Block a user