Python Flask

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?,


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: