+ 1

Code coach Days between dates (SOLVED)

Hello, I wrote this code but it works only for the first three test cases. I cannot figure out what is the problem. I would apreciate if could help me or at least give me an idea about the problem. Here is the problem: You need to calculate exactly how many days have passed between two dates. Task: Calculate how many days have passed between two input dates, and output the result. Input Format: Two strings that represent the dates, first date should be the older date. Date format: Month DD, YYYY Output Format: A number representing the number of days between the two dates. Sample Input: August 15, 1979 June 15, 2018 Sample Output: 14184 Here is the code: https://code.sololearn.com/c5MXU431EEmv/#c

19th Oct 2021, 7:31 PM
Madalina Peter
Madalina Peter - avatar
5 ответов
+ 2
Ok. Thank you. I will try that. I've tried a solution with time.h but it didn't work. I'll try this again with your advice.
20th Oct 2021, 8:23 AM
Madalina Peter
Madalina Peter - avatar
+ 1
I've succeded to do it with time.h Thank your very much for your help! Here is the code: https://code.sololearn.com/caxVrM7IhJAV
20th Oct 2021, 2:21 PM
Madalina Peter
Madalina Peter - avatar
+ 1
[Easy way with Python Solved 🥱🥱] import re from datetime import datetime da = input() de = input() a = datetime.strptime(da, '%B %d, %Y').strftime('%d/%m/%Y') b = datetime.strptime(de, '%B %d, %Y').strftime('%d/%m/%Y') aa = datetime.strptime(a,'%d/%m/%Y') bb = datetime.strptime(b,'%d/%m/%Y') diff = bb -aa print(diff.days)
1st Feb 2022, 3:23 PM
Moussa Diallo
Moussa Diallo - avatar