''' Purpose: stepping stone to nested looping ''' # get n reply = input( 'Enter number of columns: ' ) n = int( reply ) # performed repeated printing of a number series # print a line of the form row: 0 1 2 ... n-1 # ------- RANGE ----------- # range( 0,n ) # range(0,n) goes from 0 to n-1 # range(i,j) goes from i to j - 1 # ex. range(1,5) has values 1 2 3 4 print( 'row:', end=' ' ) # to do so need to first print the row: part # then on same line print out the values 0 1 2 ... n-1 one after the other # Recall print() prints on new lines by default # To get multiple things printed on the same line, we use end= for c in range( 0 , n ): # c will be each value one by one 0 1 2 3 4 ... n - 1 print( c , end=' ' ) # Now each column value c (the numbers from 0 to n) will be printed one after # the other on the same line separated by spaces # You can only use end=... in a print statement # Instead of printing on new lines (print default behavior), # we want to print on the same line with the end= separator # separating the printed output on the same line