0
for i in range(5):
What is the i part of this code for?
5 Respuestas
+ 9
it represents the current iteration of whatever it's in.
so if you do:
for i in range(0,5):
print (i)
it'll print each number it reaches the max(5)
0
1
2
3
4
you can name "i" anything though
edit: fixed it raj
+ 3
it is just a variable , it could be called anything :
ex:
for nums in range(5):
print(nums)
0
In my opnion.i is more like a flag begin with 0.as the tips says for in python is more like foreach in other language.
- 1
@ahri your loop will print from 0 to 4.
- 2
do you know this one:
for (int I=0; I <5; I++)
{
}