OneBite.Dev - Coding blog in a bite size

implement a two nested loop in python

Code snippet on how to implement a two nested loop in python

for x in range(1,5): 
    for y in range(5,8): 
        print(x,y) 

This code will print all values of x and y for which 1 <= x < 5 and 5 <= y < 8. The outer loop is a for loop that runs from x = 1 to x = 4. The inner loop is also a for loop that runs from y = 5 to y = 7. For each x, the inner loop runs and then the program returns to the outer loop. The program will print each possible combination of x and y, starting with x = 1 and y = 5 and ending with x = 4 and y = 7.

python