What are loops | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

What are loops

variable loops

17th Jan 2018, 3:13 PM
Chiquitita Martha
Chiquitita Martha - avatar
4 Answers
+ 9
a=0 while True: print("what is a loop? %s"%a) a+=1
17th Jan 2018, 3:46 PM
Ahri Fox
Ahri Fox - avatar
+ 6
Loops are used to support easy repetition of instructions, they are invented to help programmers so they don't have to rewrite or copy & paste blocks of code to repeat the instructions in the block. Theres a chapter in Python tutorial that covers loops, it's in the "Control Structures" chapter.
17th Jan 2018, 3:29 PM
Ipang
+ 2
they will repeat code as long as the condition is met
4th Feb 2018, 10:33 PM
DeleteThisAccount
0
while(condition_is_true){ do_this_stuff; } or for(initialiser, condition,inr/dcr){ do_this; } or do{ do_this; }while(condition); Use for loop when exact iterations are known directly/indirectly Else use while or do while depending on situation (note:while and for loops check condition before entering loop and do while don't hence do while gets executed at least once)
17th Jan 2018, 5:45 PM
code learner
code learner - avatar