Help With Introduction to Flask's "Adopt a Pet" Project

There is no video solution help for that project, As a beginner it is very hard to pick up.
So if anyone solved it, Please make a video and post it here…
Thank You.

1 Like

Yea, it’s still pretty new. If you have any issues though, feel free to ask. Some users here (including myself) use flask so you may get some leads.

1 Like

Can you share me the code for this project -> “Adopt a Pet”.

Thank You.

Hi again!

In the forums it’s not policy to give away answers. But if you have specific problems within the exercise that you’re stuck on, you can ask away! :slight_smile: Just remember to format the code with </> and paste any error messages as well.

I’ve been stuck in this for 2 days. Help me solve the steps from 14 to 17.

I’ve done the steps, But I dont’t know whether it is right or wrong.

Help me finish this project.

Thank You.

This seems like a matter of dealing with dictionaries.

For example:

bread = {}
bread["type"] = "pita"
bread["origin"] = "middle-east"

# {'type': 'pita', 'origin': 'middle-east'}
# pita

So all you need to do is:

  • within an h1 element
  • access the name key of pet
  • return this (as a string)
1 Like

I have been completely stumped with this project as well! So far with all of the projects I have done there was some sort of help if you get stumped, but this project has none at all. There is no forum to search, now follow along video, nothing. I’m really hoping that the rest of the web-app program isn’t like this. I just skipped the rest of the adopt-a-pet project. With no documentation I’m just staring at a screen with nowhere to go. I got stumped at the same point that the above person did. I’m not waiting around for an answer to float in so I’m moving along. I’m only writing this comment in hope that the Codecademy folks see that there is a problem with this project and gets one of their advanced coders to do a video.


For step 14, you need to assign the appropriate dictionary from within the enclosing pets dictionary to a variable named pet. Feel free to look at the file, if you would like. Use the pet function’s arguments to access the needed dictionary, as follows:

  pet = pets[pet_type][pet_id]

Try that out, then proceed to the next steps. If you encounter problems that you are unable to resolve, please post correctly formatted code for help. See How to ask good questions (and get good answers) for advice on formatting code for posting.


Here’s another thread on this

Same here, I have given up this project from 15 onward. It is pretty demotivating as it is the first project and there is no help. :((

let me know in which step were you stuck?

I also got stuck at number 12. Please help


Your syntax error occurs on line 22, but I don’t think the screenshot shows line 22 of your code. Can you screenshot that part or share the bit of the code with the issue (</> to format)?

Thanks for the help provided in the forum.
As there is not a solution available I would like to share my code.
Seems to work

from flask import Flask
from helper import pets

app = Flask(__name__)

def index():
  return '''
    <h1>Adopt a Pet!</h1>
      <p> Browse through the links bewlow to find your new furry friend </p>
        <li><a href="/animals/dogs">Dogs</a></li>
        <li><a href="/animals/cats">Cats</a></li>
        <li><a href="/animals/rabbits">Rabbits</a></li>

def animals(pet_type):
  html = f"<h1>List of {pet_type}</h1>"
  html += '<ul>'
  for idx, item in enumerate(pets[pet_type]):
      html += f'<li><a href="/animals/{pet_type}/{idx}">' + item["name"] +'</a></li>'
  html += '</ul>'
  return html

def pet(pet_type, pet_id):
  pet = pets[pet_type][pet_id]
  return f'''
  <h1> {pet["name"]} </h1>
  <img src="{pet["url"]}"/>
    <li>breed: {pet["breed"]}</li>
    <li>age: {pet["age"]}</li>

Thanks a lot! Your code helped me to solve the last task! :slight_smile: