for i in range(5): print("hello!"), output is that 5 times hello is printed, but what "i" is doing in the whole code?? | Sololearn: Learn to code for FREE!
Neuer Kurs! Jeder Programmierer sollte generative KI lernen!
Kostenlose Lektion ausprobieren
0

for i in range(5): print("hello!"), output is that 5 times hello is printed, but what "i" is doing in the whole code??

9th Jul 2019, 7:59 PM
Garima Agrawal
Garima Agrawal - avatar
3 Antworten
0
It's how for loops work. You get an iterable object, and a variable: i. i will represent that value. If you would do print(i), the output would be 0, 1, 2, 3, 4
9th Jul 2019, 8:04 PM
Airree
Airree - avatar
0
What do u mean by iterable object here ?
9th Jul 2019, 8:06 PM
Garima Agrawal
Garima Agrawal - avatar
0
Am object you can iterate through. An array, a tuple, list, and so on
9th Jul 2019, 8:07 PM
Airree
Airree - avatar