0

Lst = ["january","february","march"]

Using for loop print first three letters of each month using python

27th Nov 2019, 6:53 AM
moiz hussain
3 Antworten
+ 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
27th Nov 2019, 7:52 AM
Seb TheS
Seb TheS - avatar