This repository has been archived on 2026-10-10. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
kennels-server/views/animal_requests.py
T
2022-01-12 13:32:51 -06:00

42 lines
944 B
Python

ANIMALS = [
{
"id": 1,
"name": "Snickers",
"species": "Dog",
"locationId": 1,
"customerId": 4
},
{
"id": 2,
"name": "Gypsy",
"species": "Dog",
"locationId": 1,
"customerId": 2
},
{
"id": 3,
"name": "Blue",
"species": "Cat",
"locationId": 2,
"customerId": 1
}
]
def get_all_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