''' Purpose: demonstrate the end optional parameter for print() ''' # Introduces the end= operator # end= in a print statement basically says that we want to print the next print statement that # follows the print statement with the end= on the same line with whatever is in the end= # separating them print( 'Wa-Hoo-Wa' ) print( 'Rah-Rah-Rah' ) print(); input( "Enter when ready: " ) ; print() print( 'Wa-Hoo-Wa', end='!' ) print( 'Rah-Rah-Rah' ) # Console # Wa-Hoo-Wa!Rah-Rah-Rah # As we can see the next print statement picks up where the last print statement left off # with whatever is in the end='...' separating the two things printed # So end= lets us print on the same line! # By default, different print statements print on new lines. # end= lets you print consecutive print statements on the same line with whatever you want # separating what you're trying to print. print(); input( "Enter when ready: " ) ; print() print( 'Wa-Hoo-Wa', end='! ' ) print( 'Rah-Rah-Rah' ) # Console # Wa-Hoo-Wa! Rah-Rah-Rah print(); input( "Enter when ready: " ) ; print() for ch in 'tattarrattat' : print( ch, end='-' ) # We print out each character in this string with end='-' on the same line # In this way, it basically executes multiple print statements with all the ch's separated by hyphens # printed on the same line print() # Console # t-a-t-t-a-r-r-a-t-t-a-t- print(); input( "Enter when ready: " ) ; print() finish_seller_of_lye = 'saippuakivikauppias' for ch in 'saippuakivikauppias' : print( ch, end=' ' ) # Prints out each character one after the other with spaces separating # each character all on the same line print() # Console # s a i p p u a k i v i k a u p p i a s print(); input( "Enter when ready: " ) ; print() for ch in 'saippuakivikauppias' : print( ch, end='' ) # Now we print out each character one after the other with the empty string '' # separating each character on the same line # So you basically get the original word where each character gets printed on the same line # one after the other print() # Console # saippuakivikauppias