0 points

Nested for loop


dashboard

Tue Mar 31 2020 05:29:39 GMT+0000 (UTC)

Posted by @EnjoyByte #python #python #loops #forloop #nestedfor loop

#make two lists:
1.num_list = [1, 2, 3]
2.alpha_list = ['a', 'b', 'c']

#use for loop for 1st list:
3.for number in num_list:
#print the list    
4.print(number)
#use for loop for @nd list:    
5.for letter in alpha_list:

content_copy Copy

A for loop within another for loop is called nested for loop. The lines after # are comments python will ignore these comments while program run.