''' Purpose: introduce nested looping. for a user-supplied n, loop n times, where on the rth iteration the integers from 0 to r-1 are printed out. ''' import time # Nested Loops # for ... in ...: # for ... in ...: # statements # get n reply = input( 'Enter number of rows: ' ) n = int( reply ) # performed the repeated printing of a number series for r in range( 0, n ) : # r is each value from 0 to n - 1 # print a line of the form row r : 0 1 2 ... r. # to do so need to # first print the row r: part. # then on same line print out the values 0 1 2 ... r-1 one after the other print( 'row', r, ':' , end=' ' ) for c in range(0, r + 1): # c assumes each value from 0 to r + 1 print(c, end=' ') # print out each column value (c value) one by one on the same line separated by spaces print() # don't have the next output on the same line (print blank line on the new line) # Again, you can name your loop variables whatever you want! # r is not a specific indicator that we are going to be in a nested for loop. # Normal (Single) Loop # for ... in ...: # ... # Nested Loop # for ... in ...: # for ... in ...: # ...