While Loops In Python.

 ############## While loop Tutorial #########


i = 0

# While Condition is true
# Inside code of while keep runs

# This will keep printing 0
# while(i<45):
# print(i)

# To stop while loop
# update i to break the condition
while(i<8):
print(i)
i = i + 1
# Output :
# 0
# 1
# 2
# 3
# 4
# 5
# 6
# 7
# 8

# Assuming code inside for and while loop is same
# Both While and for loop takes almost equal time
# As both converted into same machine code

# So you can use any thing which is convenient

Comments

Popular posts from this blog

MAP FILTER AND REDUCE FUNCTION IN PYTHON

Writing Appending to a File

Recursions: Recursive Vs Iterative Approach