0

Please let me know whether my code is correct or not?

https://code.sololearn.com/c5Srw38jcJfy/?ref=app

3rd Feb 2019, 1:06 PM
Raj Charan
2 Answers
+ 3
#inspired from https://stackoverflow.com/questions/4130922/how-to-increment-datetime-by-custom-months-in-JUMP_LINK__&&__python__&&__JUMP_LINK-without-using-library import datetime import calendar def add_months(sourcedate,months): month = sourcedate.month - 1 + months year = sourcedate.year + month // 12 month = month % 12 + 1 day = min(sourcedate.day,calendar.monthrange(year,month)[1]) return datetime.date(year,month,day) six_months_ago = add_months(datetime.date.today(),-6) today=datetime.date.today() print(f"Today {today} is {('Larger',('Smaller','the same as')[today==six_months_ago])[today<six_months_ago]} than {six_months_ago }")
3rd Feb 2019, 2:52 PM
Louis
Louis - avatar
0
You can't use dateutil module in Sololearn. It is not supported
3rd Feb 2019, 2:05 PM
Maneren
Maneren - avatar