+ 5
When it says import random for i in range(5): value = random.randint(1, 6) print(value) What does the 'i' mean?
Sorry if I sound stupid
12 odpowiedzi
+ 6
I think 'for i in range(5)' means 'for every item in range(5)'. The 'i' could be any letter or word so you could write 'for num in range(5)' and then 'num' would be each number in the range you have created. I think of 'i' as a placeholder for each item in the list that follows.
+ 5
"i "is a simple name, you can replace it with any kind of letters. it represent the index of all value in range. when you type | for i in range ...| is the same as you tell the pc |for all value in range indexed by "i" name...|
+ 4
i is a temporary variable
+ 1
in the programing world,we usually using the letters I,j, k in for and while loops.you could replace it with just num for example,but it is a "tradition"
+ 1
I like to think of i as meaning iteration or index, even though it is just a variable. That's just how I think of it when I see it, so I actually use i as the variable for for loops most of the time, unless I am worried about code readability or am looping through key/vals or such.
+ 1
like Marco says "i" is thé index of all the values in range. Here web have range(6) consider lit ligne an array of 6 elements and "i" will take the value between 0 and 5 such that 0 is the index of de first box like wise and 5 ils the last box.
+ 1
"i" just stands for any interger value within the given range
0
"i" is just a counter, that passes values from 1 to 5, and for each time the program carries out some actions (calls a module "random" and prints the result of processing). Here "i" is like a metronome.
0
As mentioned by the other users. It's an increment with the index name 'i' . It helps to name similar to the range your cycling through eg for car in vehicles. P.S. Your never stupid for asking it's a good networking tool to ask.
0
As everyone said, I is just a counter variable, so you could just use _ to tell Python to ignore the result of the current iteration of range
0
the 'i' here is just a temporary variable.
0
for i in range(5): means
i=0 to i=4