Blog Introductions
In this blog contains tutorials about HTML Tutorials, Python Tutorials, CSS Tutorials, How to, PHP Tutorials, Java Tutorials, C++ Tutorials, Tutorials, Examples, Source code,Learning,
Tips and Software development services. Python loops and control flow | Python tutorials Bestitworriors
In this blog contains tutorials about HTML Tutorials, Python Tutorials, CSS Tutorials, How to, PHP Tutorials, Java Tutorials, C++ Tutorials, Tutorials, Examples, Source code,Learning,
Tips and Software development services. Python loops and control flow | Python tutorials Bestitworriors
Python loops and control flow
Python loops and control flow | Python tutorials Bestitworriors - Loop are use to repeat the specific part of code in number of iteration given.Loop are use to print the code in multiple time as you want.Python support for loops and while loops and etc much more.Loop will iterate untill react to given number of iterations.
Some Key Points of Python Loops
- Loops iterate untill specific condation match
- Python support while loop
- Python support for loop
- For Loop iterate array also
- Loop contain break and continue statements
- Break statement will break the loop on given condation
- Continue statement switch the given iteration
- We can use else part to while loop when while end then else part will execute
Code
var1 = 1
while var1 < 6:
print(var1)
var1 += 1
var2 = 1
while var2 < 6:
print(var2)
var2 += 1
else:
print("Var2 is no longer less than 6")
Months = ["January", "Feburary", "March", "April", "May", "June", "Jully"]
for x in Months:
if x == "January":
continue
if x == "June":
break
print(x)
OutPut
1
2
3
4
5
1
2
3
4
5
Var2 is no longer less than 6
Feburary
March
April
May
0 Comments