''' Purpose: introduce nested looping. for a user-supplied n, loop n times, where on the ith iteration the integers from 0 to i are printed out. ''' import time # get n reply = input( 'Enter number: ' ) n = int( reply ) # performed the repeated printing of a number series for i in range( 0, n + 1 ) : # print a line of the form i: 0 1 2 ... i print( i, ':', end=' ' ) for lv in range(0, i + 1): # 0 to i # print a line of the form i: 0 1 2 ... i (range(0, i+1)) print(lv, end=' ') # How can I change this??? print() # prints a blank line/tells you to go to the next line # It's important to keep in mind the indentation of your # statements in your for loop. # What are we doing for each loop variable value? The statements indented # into it! # It's important to visualize how a nested loop works. We should keep # the values of i and lv in mind as we run through this loop # and we should know that for each value of i, we are doing # three things (print i:, print all values leading up to i, and # print out a blank line after that to separate each line of output) # 0: comes from line 16 # 0: 0 # ^ this part right here comes from lines 17-19 # 1: comes from line 16 # 1: 01 # ^ this part comes from lines 17-19