''' Purpose: introduce nested looping. ''' # get number of rows reply = input( 'Enter number of rows: ' ) n = int( reply ) # performed the repeated printing of a number series for r in range( 0, n ) : # print a line of the form r+0 r+1 ... r+n-1 print( 'row',r,':', end=' ') for c in range( 0, n ): # What do we want to print? r+c (so we need a variable to store the sum of r+c) total = r + c # Can we use end= to print it? print( total, end=' ' ) # print out each c value one after another print() # for each r value we want to do two things: # c loop (line 13) # print out a blank print to go to the next line of output for the next row (line 18) # We complete the c loop for each value of r # We calculate r + c since c changes and r remains the same for that r value # and we print all the c values on the same line using end=' ' to # print each number separated by spaces