Answers for "use of nested loop"

3

nested loop

for a in range(1,3):
    if a%2!=0:
        print(a,end=" ")
        
    for b in range(1,a+1):
        if b%5==0:
         print(b,end=" ")
         
        for c in range(a,b+1):
            if c%3!=0:
             print(c,end=" ")

    print()
Posted by: Guest on December-12-2021
0

What is the purpose of a nested loop?

What is the purpose of a nested loop? 

Nested loops are useful when for each pass through the outer loop, you need to repeat some action on the data in the outer loop. For example, you read a file line by line and for each line you must count how many times the word “the” is found.
Posted by: Guest on November-19-2021

Python Answers by Framework

Browse Popular Code Answers by Language