Context:
I'm following this Flask tutorial.. it has little quizzes and such to help you learn; but at times it asks you to finish code. I got stuck here and forced to looked at their solution.
Knowledge cut off:
I don't understand syntax in python loops very well...
I understand the c++/ java loops well
string pets [3] == {cat,dog,chicken};
for(int i=0 i > pets.size();i++){
}
cool
Question:
but here is what i'm trying to understand
Where the heck does 'pet' come from and how do you iterate through them like that.. pets, sure
but for 'pet' in pets.. what?
How does this work?
Question with code:
home.html
{% for pet in pets %}
<tr>
<td ><img src= "{{url_for('static', filename = pet["id"]|string+".jpg")}}" height="100" ></td>
<td>{{ pet["name"] }}</td>
<td>{{ pet["age"] }}</td>
<td>{{ pet["bio"] }}</td>
</tr>
{% endfor %}
pets = [
{"id": 1, "name": "Nelly", "age": "5 weeks", "bio": "I am a tiny kitten rescued by the good people at Paws Rescue Center. I love squeaky toys and cuddles."},
{"id": 2, "name": "Yuki", "age": "8 months", "bio": "I am a handsome gentle-cat. I like to dress up in bow ties."},
{"id": 3, "name": "Basker", "age": "1 year", "bio": "I love barking. But, I love my friends more."},
{"id": 4, "name": "Mr. Furrkins", "age": "5 years", "bio": "Probably napping."},
]