Python Nested for Loops Practice Exercises

Asha Ganesh
3 min readJun 9, 2020

--

Before going through this blog better go through the basic for loops

Nested For Loops — Loops can be iterate in python
A nested loop with in a loop that occur within another loop.

syntax:
f or (first iterable variable) in (outer loop):
[statements]

for (second iterable variable) in (nested loop):
[statements]

Exercise 1: Write question words 3 times using nested loops

observe how outer and inner loops are iterating

Nested for loops can be useful for iterating through items with in list composed of lists.In list composed of lists ,if we employ just one for loop ,the program will output each internal list as and item

Exercise 2 : Use single for loop to access each list

looping list elements in list with in a list

Exercise 3 : Using Nested for loop access each individual element from list with in the list

iteration through the values in list with in the list

Exercise 4 : Multiply with place values[10’s,100’s] to the given lists

multiply with place values through nested for loops

Exercise 5: print the fallowing output

1
2 2
3 3 3
4 4 4 4

Number pattern

Exercise 6: Skip ovals to print from the sentence ‘Python Logic For Kids’

remove ovals

Exercise 7 : Print the * pattern using nested for loops

*
* *
* * *
* * * *
* * * * *
* * * *
* * *
* *
*

pattern using nested loops

Exercise 8 : Print given pattern

*
**
***
****

print single star at first row 2 stars in the second row and continue
doing this in a similar fashion

patterns using nested for loops

Exercise 9 :Print odd number patterns

*
***
*****
*******

odd number starts patterns

Exercise 10 : Print Alphabets

A
B C
D E F
G H I J
K L M N O

print alphabet pattern

Exercise 11 : Print A one time B two times …

A
B B
C C C
D D D D
E E E E E

Alphabet Pattern

# Exercise 12 : Print your name in 3 rows and columns

Will meet with many exercises with ‘break’ and ‘continue’ with loops in python.

“If you have knowledge ,let others light their candles in it”

Happy to share :) …

--

--