Answer to Question #265808 in Python for Latha

Question #265808

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

1
Expert's answer
2021-11-14T09:22:35-0500


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



Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS