Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialPranshu Mittal
4,276 PointsI am not able to identify the error in my code
I am getting the desired output when i run the same code in Jupyter Notebook, but here it says Try Again! Could anyone tell me what is the problem with my code?
import datetime
def minutes():
now = datetime.datetime.now()
today = datetime.datetime.today() - datetime.timedelta(hours = 5)
timediff = now - today
seconds = datetime.timedelta.total_seconds(timediff)
total_diff = round(seconds/60)
return total_diff
1 Answer
Steven Parker
231,236 PointsWhere the instructions say "Write a function named minutes that takes two datetimes...", they mean that the function needs to have two parameters and the caller will be providing both values as arguments.
The comparison needs to be done on the passed parameters and you won't need to sample the current time/date at all.
Pranshu Mittal
4,276 PointsPranshu Mittal
4,276 PointsYeah i figured it out after sometime. Anyways..Thank you so much!
Steven Parker
231,236 PointsSteven Parker
231,236 PointsPranshu Mittal — Glad to help. You can mark a question solved by choosing a "best answer".
And happy coding!