''' Purpose(s): String chrestomathics Motivate the need for looping ''' ADAGE = "Love is all you need" # prompt and get from user the number of occurrences to be printed reply = input( "Enter number of lines to be printed: " ) n = int( reply ) # print the n occurrences of the string of interest # '\n' is the newline character output = (ADAGE + '\n')* n # This will concatenate the string together n times in one line print(output) # We want the string PRINTED on separate lines (so basically like calling the print function n times) # Introduction to For Loop: # Lets you repeat work # Repeats code statements many times (a finite number of times) # Structure: # for loopvariable in sequence: # statements to repeat (indented in) # Do something n times for i in range( 0,n ): # Does this 0 to n - 1 times (0th time, 1st time, 2nd time, ... - it's still n times!) print( i, ADAGE ) # WRITE THIS DOWN: # Range(i,j) -> Assumes values i to j - 1 # A range(0,5) will have values 0,1,2,3,4 (not 5!) # NEVER forget the range! Because then it will only do it for the two values in the tuple (i,j) (0th time and 6th time) # REMEMBER range(i,j)