+ 1

for i in range(21) ?

can someone explain to me what does for i in range mean ? please.

2nd Jul 2020, 5:01 PM
Merveille Mitch
Merveille Mitch - avatar
3 Answers
+ 4
"i" is assumed as the local variable in the statement. It has no value outside the range. It is a temporary variable for creating range. you can use any variable in place of "i". "i" is commonly used to represent iterator For more explanation, see these threads:- https://www.sololearn.com/discuss/236319/?ref=app https://www.sololearn.com/discuss/1922018/?ref=app
2nd Jul 2020, 5:08 PM
Arctic Fox
Arctic Fox - avatar
+ 4
i is just a variable used in the loop. You can change and make it c, p, j , etc........ Just to define the value
2nd Jul 2020, 5:19 PM
Nilesh
Nilesh - avatar
+ 2
hi mitch “range(21)” - a function producing numbers ranged 0 through 20 (essentially 21 numbers.. starting with 0) “for i in” - for loop which iterates over the function “range(21)” think of “i” as a variable, it represents the instance of each number produced by range so there will be 21 iterations starting with the number 0 in this loop
2nd Jul 2020, 8:53 PM
madeline
madeline - avatar