I really do not get this loop stuff, please can anyone explain it in a better and understandable way | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

I really do not get this loop stuff, please can anyone explain it in a better and understandable way

Looping in pyton

6th Jul 2020, 12:29 PM
Great Guy
Great Guy - avatar
2 Answers
+ 1
looping is used to do something over and over again. potentally an infinite amount of times.
6th Jul 2020, 12:44 PM
Slick
Slick - avatar
+ 1
Eg: you need to print something 1000 times. Instead of doing: print("Hi") print("Hi") print("Hi") print("Hi") ... 1000 times, you could simply do: for i in range(1000): print("Hi") As you see, the code is way shorter. Also, you can't write print a variable number of times, i.e. If you allow the user to enter a number and say hi that many times.
6th Jul 2020, 12:53 PM
Arnesh
Arnesh - avatar