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.

16th Mar 2017, 7:41 AM
Bassem Kabesh
Bassem Kabesh - avatar
9 Réponses
16th Mar 2017, 7:59 PM
Kuba Siekierzyński
Kuba Siekierzyński - avatar
+ 5
Hard to tell, since I haven't seen the question :)
17th Mar 2017, 7:28 AM
Kuba Siekierzyński
Kuba Siekierzyński - avatar
+ 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
16th Mar 2017, 7:00 PM
Kuba Siekierzyński
Kuba Siekierzyński - avatar
+ 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
16th Mar 2017, 7:34 PM
Kuba Siekierzyński
Kuba Siekierzyński - avatar
+ 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.
16th Mar 2017, 8:53 PM
Kuba Siekierzyński
Kuba Siekierzyński - avatar
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
16th Mar 2017, 7:29 PM
Bassem Kabesh
Bassem Kabesh - avatar
0
said unsupported operand type(s) for -: tuple and int 😐
16th Mar 2017, 7:42 PM
Bassem Kabesh
Bassem Kabesh - avatar
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
16th Mar 2017, 8:10 PM
Bassem Kabesh
Bassem Kabesh - avatar
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
17th Mar 2017, 7:22 AM
Bassem Kabesh
Bassem Kabesh - avatar