0
Lst = ["january","february","march"]
Using for loop print first three letters of each month using python
1 Answer
+ 3
For loop is a statement that has a variable, that goes through any list.
numbers = [7, 23, 4, 9, 10]
for i in numbers:
print(i)
Is a shortcut for:
i = numbers[0]
print(i)
i = numbers[1]
print(i)
...
i = numbers[4]
print(i)
Output is the same for both:
7
23
4
9
10
Its advantage is not only that it requires less code, but it's another advantage is that the list can be of any size and the loop will still work.
https://code.sololearn.com/c0UzSHgR7HqX/?ref=app