# breaks_1.py # Example of simple "for" loop with "break" operation # # general form: for in : # def main(): dash = "-" special_char = "*" line_length = input("Enter line length: ") special_char_location = input("Enter char location: ") segment_1 = dash * (special_char_location - 1) segment_2 = dash * (line_length - special_char_location) print segment_1 + special_char + segment_2 print "-----" dash = "-" special_char = "*" mid_point = "|" line_length = 21 special_char_location = 13 mid_point_location = line_length / 2 if mid_point_location > special_char_location: segment_1 = dash * (special_char_location - 1) segment_2 = dash * (line_length - special_char_location) print segment_1 + special_char + segment_2 dash = "-" special_char = "*" line_length = 20 special_char_location = 13 segment_1 = dash * (special_char_location - 1) segment_2 = dash * (line_length - special_char_location) print segment_1 + special_char + segment_2 print print "-----" print "Welcome to Sub-Menu Selector" print print "Select an option below:" print " 1 - Print OK" print " 2 - Add two numbers" print " 3 - Exit" print for i in range(999): x = input("Enter option: ") if x == 1: print "OK" elif x == 2: x,y = input("Enter #,#: ") print x+y elif x == 3: print "Bye, Bye..." break else: print "Incorrect option, try again..." print "-----" print "Welcome to Menu Selector" print print "Select an option below:" print " 1 - Print OK" print " 2 - Add 3+5" print " 3 - Exit" print for i in range(5): x = input("Enter option: ") if x == 1: print "OK" elif x == 2: print 3+5 elif x == 3: print "Bye, Bye..." break else: print "Incorrect option, try again..." print "-----" for i in range(999): x = input("Enter number (type exit to stop): ") if x == 10: print "Magic number!" elif x != "exit": print x else: print "Outta here..." break exit = "exit" for i in range(999): x = input("Enter number (type exit to stop): ") if x == 10: print "Magic number!" elif x != exit: print x else: print "Outta here..." break print "-----" for i in range(999): x = input("Enter number (-1 to stop): ") if x == 10: print "Magic number!" elif x != -1: print x else: print "Outta here..." break print "-----" for i in range(999): x = input("Enter number (-1 to stop): ") if x != -1: print x elif x == 10: print "Magic number!" else: print "Outta here..." break print "-----" for i in range(999): x = input("Enter number (-1 to stop): ") if x != -1: print x else: print "Outta here..." break print "-----" for i in range(3): x = input("Enter number (1-3): ") if x == 1: print "OK" elif x == 2: print 3+5 elif x == 3: print "Cloudy" print "Welcome to Menu Selector" print print "Select an option below:" print " 1 - Print OK" print " 2 - Add 3+5" print " 3 - Print the weather" print for i in range(4): x = input("Enter option: ") if x == 1: print "OK" elif x == 2: print 3+5 elif x == 3: print "Cloudy" else: print "Incorrect option, try again..." print "-----" for i in range(5): if i == 3: print "Outta here..." break else: print i print "-----" main()