When I use for loop I type for I in list_name .. what is I !? Any one can show that to me !? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

When I use for loop I type for I in list_name .. what is I !? Any one can show that to me !?

25th Apr 2017, 10:41 PM
ahmed elmousel
ahmed elmousel - avatar
5 Answers
+ 11
The way a for works is like this: for every_item in this_array <loop this code> So when you write: for i in list_name <your code> i will stand for every item in list_name, from 0 to its last item, and loop until it uses all of the items. Ex: On the first loop, i = list_name[0]
25th Apr 2017, 11:11 PM
Tamra
Tamra - avatar
+ 3
I believe it's short for iterator >> https://en.wikipedia.org/wiki/Iterator Also, it doesn't actually need to be an 'i' - see these previous answers to a similar question >> https://www.sololearn.com/Discuss/207139/what-does-the-i-in-most-JUMP_LINK__&&__python__&&__JUMP_LINK-for-loops-stand-for
26th Apr 2017, 12:23 AM
Lium Goon
Lium Goon - avatar
0
can you be little more clear ?
25th Apr 2017, 10:54 PM
learner
learner - avatar
0
i is just a variable, it can be anything. myList=[1,2,3] for i in myList: print(i) output: 1 2 3 each time it loops, the variable i=the index of the list the loop is on. if the loop is on loop 0, i becomes myList[0].. the next time the loop runs, i becomes myList[1].. etc
26th Apr 2017, 1:11 AM
LordHill
LordHill - avatar
0
i can be anything. Just notice: Integer=int
27th Apr 2017, 9:05 AM
mei
mei - avatar