Wednesday, June 27, 2012

Display Month Function

month = raw_input("Enter the number of month")

try:
    month = int(month) - 1
    if month < 0 or month >= 12:
        print "Please enter between 1 to 12"
        exit()

except:
    print "Error"
    exit()

def displayMonth(month):
    listOfMonth = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
    return listOfMonth[month]

print displayMonth(month)

Purpose of this code:
- Calculate the number of month and display the month's name
* Plans to take in day & year of birthday
* To calculate horoscope and chinese zodiac

No comments:

Post a Comment