for x in sequence: for y in sequence:
The outer loop can contain more than one inner loop without limitation on the chaining of loops.
Python nested for example
Simple example code for Nested loop to print multiplication table in Python
for i in range(0, 5): for j in range(0, 5): print(i * j, end=' ') print()
Nested for Loop to Print Pattern.
rows = 5 # outer loop for i in range(1, rows + 1): # inner loop for j in range(1, i + 1): print("*", end=" ") print('')
* * * * * * * * * * * * * * *
Do comment if you have any doubts and suggestions son this Python nested topic.
Note: IDE: PyCharm 2021.1.3 (Community Edition)
All Python Examples are in Python 3, so Maybe its different from python 2 or upgraded versions.
Degree in Computer Science and Engineer: App Developer and has multiple Programming languages experience. Enthusiasm for technology & like learning technical.