''' Purpose: demonstrate the end optional parameter for print() ''' import pause # each print statement prints its thing on a new line # these two print statements will print the strings on each new line print( 'Wa-Hoo-Wa' ) print( 'Rah-Rah-Rah' ) print(); input( "Enter when ready: " ) ; print() # sometimes, you may want separate print statement to print on the same line # as in don't automatically print on a new line print( 'Wa-Hoo-Wa', end='!' ) # end='' end=followed by a string # tells the print statement to print the thing after end= # BUT then don't go to a new line for the next print statement print( 'Rah-Rah-Rah' ) # this print statement will print 'Rah-Rah-Rah' on the same # line as the previous string 'Wa-Hoo-Wa' and after the '!' print(); input( "Enter when ready: " ) ; print() print( 'Wa-Hoo-Wa', end='! ' ) # we add a space after '!'; the string after end= can be any string print( 'Rah-Rah-Rah' ) print(); pause.until_ready(); print() # for each character in 'tattarrattat', print the character one at a time # but don't print them on different line like usual # we want that after each character, we want a - and then print the next characters and the following - # on the same line for ch in 'tattarrattat' : print( ch, end='-' ) print() # we end the end= with an empty print() - prints a new line print(); pause.until_ready(); print() finish_seller_of_lye = 'saippuakivikauppias' # for each character in finish_seller_of_lye, # we want to print the character, a space, then the rest of the characters and the following ' ' # on the same line for ch in finish_seller_of_lye : print( ch, end=' ' ) print() print(); pause.until_ready(); print() # for each character in finish_seller_of_lye # we want to print the character, empty string, and other characters and the following '' on the same line for ch in finish_seller_of_lye : print( ch, end='' ) print()