how to restart a loop in python code example
Example 1: how to restart loop python
i=2
while i < n:
if something:
do something
i += 1
else:
do something else
i = 2 #restart the loop
Example 2: how to exit a loop in python
print("enter a number")
num=int(input())
for i in range(2,num+1):
if(num%i==0):
print("smallest divisor is",i)
break
Example 3: how to exit a loop in python programix
for letter in 'Python': # First Example
if letter == 'h':
break
print 'Current Letter :', letter