- 2

Can you please explain me this

15th Jun 2017, 5:44 AM
sai saketh solasa
sai saketh solasa - avatar
4 Answers
+ 7
Loop envelopes a part of the code to run this part more than once. "For" loop runs it a specified number of times, "while" - until its condition is False. Potential uses include: iteration over a collection variable, repeated execution of the code until user action is activated and so on.
15th Jun 2017, 5:52 AM
Kuba SiekierzyƄski
Kuba SiekierzyƄski - avatar
+ 3
Use of loop in Python is not trivial, as it doesn't follow the classical model of for (initialization, test, incrementation), but rather iterate over a list... So, you can loop over a list content, and the range() function is made with that meaning: it return a generated list of integers, from a starting to an ending value (not included), with a specific step. Default value for start is zero, default step is one... you'll be required to pass at least one parameter for the boundary ending value: range(5) == [ 0, 1, 2, 3, 4 ], while 2 parameters are expected to be start then end, and a third one added is the step value (wich can obviously be negative) ^^
15th Jun 2017, 8:57 AM
visph
visph - avatar
+ 1
Post the code you're having trouble with.
15th Jun 2017, 5:48 AM
Igor B
Igor B - avatar
0
for i in range(5): print("hello!")
15th Jun 2017, 5:49 AM
sai saketh solasa
sai saketh solasa - avatar