# Sentence.py Copyright (c) 2006 Kari Laitinen # http://www.naturalprogramming.com # 2006-05-27 File created. # 2006-05-27 Last modification. # The corresponding Java and C++ programs show some strange # aspects related to switch-case constructs. Because Python does # not provide switch-case constructs, this is quite an # unnecessary program. However, I whote this program so that # it behaves almost like the corresponding program in the Java # book. print "\n Type in L, M, or S, depending on whether you want" \ "\n a long, medium, or short sentence displayed: ", character_from_keyboard = raw_input().upper() complete_sentence = \ [ "\n This is a", "switch statement in a \n ", "program in a", "book that teaches Java programming.", "\n I hope that this is an interesting book.\n" ] if character_from_keyboard == 'S' : complete_sentence.pop( 1 ) # remove second string from the list complete_sentence.pop( 1 ) # remove also the new second string elif character_from_keyboard == 'M' : complete_sentence.pop( 1 ) for part_of_sentence in complete_sentence : print part_of_sentence,