Python Flask

https://www.codecademy.com/paths/build-python-web-apps-flask/tracks/introduction-to-flask/modules/introduction-to-flask/projects/adopt-a-pet

I1m trying to set the last route /‘animals/pet_type/pet_id’ but i don1t know how to insert the value stored in the for loop in the href tag. can anyone help?,

@app.route(’/animals/string:pet_type’)

def animals(pet_type):

html = f’’’

List of {pet_type}

‘’’

html += ‘

    for idx, i in enumerate(pets[pet_type]):

  name = i['name'];

  html += f"<li> <a href = '{{/animals/pet_type/idx}}'> {name} </a> </li>"

html += ‘

return html

Hello, @lucasof, and welcome to the Codecademy Forums!

Try this inside the loop:

    html += "<li>" + f'<a href="/animals/{pet_type}/{idx}">' + item["name"] + "</a></li>"

As a result, on localhost, Shadow’s url would be:

https://localhost/animals/dogs/1