0

i need to use spyder to convert time and date using tuples.

it is like that def problem3_3(month, day, year).Write a function that will convert a date from one format to another.

Specifically, 06/10/2016 should convert to June 17, 2016. Actually, you will input the 6, the 17, and the 2016 as separate integers (numbers) and the function will assemble and print the date as June 17, 2016.

I suggest that you create a tuple months = ("January", "February", "March", ...) to store the names of the months. Then it is easy to access the name February as months[1] and so on.. please help. thanks

EAK TEAM
  • 5,726
  • 4
  • 30
  • 52
  • thanks sir, but can i concatenate and how, because it gives me this error(TypeError: can only concatenate tuple (not "str") to tuple) – Bassem Kabesh Mar 15 '17 at 14:30
  • Possible duplicate of [Parse date string and change format](http://stackoverflow.com/questions/2265357/parse-date-string-and-change-format) – Amin Etesamian Mar 15 '17 at 14:42

1 Answers1

0
def problem3_3(month, day, year):
""" Takes date of form mm/dd/yyyy and writes it in form June 17, 2016 
    Example3_3: problem3_3(6, 17, 2016) gives June 17, 2016 """
months=("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December")

for month in months:

    #print (month[5] +" "+str(day)+", "+str(year))
    print (months[month-1] +" "+ str(day)+", "+ str(year))
pritaeas
  • 2,073
  • 5
  • 34
  • 51