0
Convert date time format to another
i need to convert 06/10/2016 to june 17, 2016 in that order. and that by using tuple. how can i do that.
9 Réponses
+ 5
Hmm... works for me:
https://code.sololearn.com/crgVNxIU9Cdy/?ref=app
+ 5
Hard to tell, since I haven't seen the question :)
+ 4
Hmm... maybe try defining a tuple months = ('January', 'February', ..., 'December') and then return the (MM-1)th element of the tuple as the month name.
def full_date(date):
months = ('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December')
return months[int(date[0:2])-1] + ' ' + date[3:5] + ', ' + date[6:]
print(full_date('06/17/2016'))
>>>
June 17, 2016
+ 4
Oh, that's even simpler:
def full_date(m, d, y):
months = ('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December')
return months[m-1] + ' ' + str(d) + ', ' + str(y)
print(full_date(6, 17, 2016))
>>>
June 17, 2016
+ 4
I see... Autograders often expect *exactly* the same output as questioned, so maybe try to manipulate with the return formula to get exactly the correct answer.
0
it is working, but that's not what he wants. the question is like this. write a function that will convert a date from one format to another specifically, 6/10/2016 should convert to june 17, 2016. and he suggest using tuple for the months for easy access as an item [], so when you write on the def (6,17,2016) it will print june 17, 2016
0
said unsupported operand type(s) for -: tuple and int 😐
0
thanks man forb your help, it is working with me as well, but the auto grader say it failed the test case, so no idea what he wants
0
do you think i need to put the date 06/10/2016 some where in the code, sonce he mentioned it in the question