-1

i m currently working in Generating dynamic invoice on monthly basis but i m stuck in getting month name in python from user input date

Example: Given Date is :15/03/2020 is date and month is March

Any help would be appreciated

1 Answers1

0

Assuming that you are receiving the date in the form of a string like "15/03/2020":

int(date.split('/')[1]) returns the value between the first and second / of date as an integer. This can then be used as the index for a list of month names to return the name of the month:

months = ["January","February","March",...]
print(months[int(date.split('/')[1])-1])
The Zach Man
  • 738
  • 5
  • 15