How many loops Python have?What are those loops?
Do you know how many loops Python support?
Python language has only two loops:
In above example it will print until cal is less than 10.
Syntax of For loop:
|for i in iterating_object: |
# show some output
All the statements inside "for" and "while" loop should be indented to the same number of spaces. Otherwise it will throw the SyntaxError .
for i in my_result:
This range(a, b) functions returns sequence of integers from a , a + 1 , a+ 2 …. , b - 2 , b - 1 .
|for i in range(5, 20):|
While loop keeps executing statements inside it until condition becomes false.
After each iteration condition is checked and if its True then once again statements inside the while loop will be executed.
Syntax of While loop is :
|cal = 0
while cal < 10:
cal += 1
Tech writer at newsandstory
Total 561 views