# Author: James Tam # Version: September 29, 2014 # This version error checks the month entered and repeatedly # prompts for a value until a value with the correct range # has been entered. # Maps a numeric value to the name of the month # Error message displayed if an invalid numeric value entered. MIN_MONTH = 1 MAX_MONTH = 12 JAN = 1 FEB = 2 MAR = 3 APR = 4 MAY = 5 JUN = 6 JUL = 7 AUG = 8 SEP = 9 OCT = 10 NOV = 11 DEC = 12 month = 0 while ((month < MIN_MONTH) or (month > MAX_MONTH)): month = int(input("Enter month (1 - 12): ")) if ((month < MIN_MONTH) or (month > MAX_MONTH)): print("Month must be a value between 1 - 12") print("Month is...", end="") if (month == JAN): print("January") elif (month == FEB): print("February") elif (month == MAR): print("March") elif (month == APR): print("April") elif (month == MAY): print("May") elif (month == JUN): print("June") elif (month == JUL): print("July") elif (month == AUG): print("August") elif (month == SEP): print("September") elif (month == OCT): print("October") elif (month == NOV): print("November") elif (month == DEC): print("December") else: print("Months only range from 1 - 12")