We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
- Prepare
- Python
- Date and Time
- Time Delta
- Discussions
Time Delta
Time Delta
Sort by
recency
|
390 Discussions
|
Please Login in order to post a comment
I meet some difficulties to solve this problem because I first think that we have to used Calendar module. But in fact, we have to use datetime module. From the documentation, we have a full table with all meaning of %a, %b etc...
Once we have this knowledge, we can just go step by step by solving each error one after one.
Here, I convert both datetime in delta_time thanks to the conversion value of the documentation.
Then, I do the difference.
Finally, because test case 1 and 2 were not solved cause of values like "-123456" instead of "123456", I just add a small if/else condition to remove this possible "-".
Here the code :
Here is HackerRank Time Delta in python solution - https://programmingoneonone.com/hackerrank-time-delta-problem-solution-in-python.html
#!/bin/python3 from datetime import datetime import math import os import random import re import sys
Complete the time_delta function below.
def time_delta(t1, t2):
if name == 'main': fptr = open(os.environ['OUTPUT_PATH'], 'w')