# Words.py Copyright (c) Kari Laitinen # http://www.naturalprogramming.com # 2006-05-27 File created. # 2022-12-16 Converted to Python 3. # This program uses the standard input() function. Indexing is # used to access the individual characters of the # given sentence. # Python programs have the same kind of block structure # as programs written with other programming languages. # No braces { } are needed to specify where a block # starts or were it ends. Instead, indentation of program # statements are used to identify program blocks. # Statements beginning in the same column belong to the # same program block. print( "\n This program separates the words of a" \ "\n sentence and prints them in wide form." \ "\n Type in a sentence.\n\n ", end="" ) given_sentence = input() character_index = 0 print( "\n ", end="" ) while character_index < len( given_sentence ) : character_in_sentence = given_sentence[ character_index ] if character_in_sentence == ' ' : print( "\n ", end="" ) else : # A space character is printed after each visible character. print( character_in_sentence, end=" " ) character_index += 1 print( "\n" )