0

What is the best pythonic way to covert, a string as '11-2020' to 'NOV-2020' in Python.

I tried below code :

print(datetime.datetime.strptime(date, '%m-%Y').strftime('%b-%Y'))

But getting output like : Nov-2020 (I want Nov to be in caps)

KKL
  • 85
  • 5

1 Answers1

1
print(datetime.datetime.strptime(date, '%m-%Y').strftime('%b-%Y').upper())
#NOV-2020
Mitchell Olislagers
  • 1,758
  • 1
  • 4
  • 10