+ 2

Python.

here... 1. for i in range(5): 2. print("hello!") in line 1 for i in range(5): prints numbers from 0 to 4. and in line 2 i also know that print("hello") prints hello. but what i dont understand is how it prints hello five times. is it because the line 2 is indented

27th Jul 2017, 6:25 PM
stephen haokip
stephen haokip - avatar
2 odpowiedzi
+ 6
because 0,1,2,3,4 are 5 numbers, since 0 also counts (:
27th Jul 2017, 6:36 PM
Maya
Maya - avatar
+ 4
Becouse range is iterete numbers from 0 to 4, and cicle for do five iterations. Function print("hello!") in a body of a cicle, and calls five times.
27th Jul 2017, 6:43 PM
shaldem
shaldem - avatar