Give the number of the month , write a program to print the name of the month
Input will be a single line Containing a integer N
SOLUTION TO THE ABOVE QUESTION
SOLUTION CODE
print("\nINPUT:\n")
#propmt the user to enter a number
my_month_number = int(input("Enter the number of the month: "))
#declare a list and store the names of all the months of the year
my_months_names_list = ["January", "February", "March", "April", "May", "June",
"July", "August", "September", "October", "November", "December"]
print("\nOUTPUT:\n")
if(my_month_number >0 and my_month_number<=12):
print("The month in number "+str(my_month_number)+" is "+str(my_months_names_list[my_month_number-1])+"\n")
elif my_month_number < 0:
print("Months number can not be negative.")
else:
print("Months number can not be greatet than 12.")
SAMPLE PROGRAM OUTPUT
Comments
Leave a comment