0
For loop
in question letters = ['a','b'] for l in letters: print(l) what does 'l' indicate? is l is constant or variable?
4 Answers
+ 2
It's a variable. As the loop iterates through the array, it gets each element's value assigned to it one after another.
First iteration: l = 'a', so when you print l, it prints 'a'.
Second iteration: l = 'b', so it prints 'b'.
If you added more elements it would continue the same way with the rest of them.
Also, it doesn't have to be l, you can use any letter.
+ 1
letters = ['a', 'b', 'c']
for l in letters :
print(l)
Right answer
0
similar to for i in range(0,10) loops from 0 to 9 for l in letters loops from 0 to len(letters)
0
letters = ['a', 'b', 'c']
for l in letters :
print(l)