for-loops
for <loop variable> in <sequence>:
<loop body>
Performs the loop body for every element of the sequence.
- Components:
- loop variable : variable
- Variable that will take on the value of every element in the -sequence at some point in the loop. Any valid variable is acceptable.
- sequence : iterable object
- e.g. Arrays, Lists, Strings
- loop body : .
- Code to be executed for every element of sequence.
- Results:
- Output of loop body
pets
Index | ID | Species | Age | Weight |
---|---|---|---|---|
0 | dog_001 | dog | 5 | 40 |
1 | cat_001 | cat | 0.2 | 1.5 |
2 | cat_002 | cat | 9 | 15 |
3 | dog_002 | dog | 2 | 80 |
4 | dog_003 | dog | 0.5 | 25 |
5 | ham_001 | hamster | 3 | 1 |
6 | ham_002 | hamster | 0.2 | 0.25 |
7 | cat_003 | cat | 0 | 10 |