Python Dates and Times in Python Let's Build a Timed Quiz App Simple Time Machine

Brent Liang
Brent Liang
Pro Student 2,944 Points

Code challenge question

Question asks to write a function named delorean that takes an integer &return a datetime that is that many hours ahead.

What's wrong with my code?
import datetime
def delorean (num):
    starter = datetime.datetime(2015, 10, 21, 16, 29)
    endtime = starter + datetime.timedelta (hours = num)
    return endtime

2 Answers

Ryan S
Ryan S
27,264 Points

Hi Brent,

The issue is that the "starter" variable that was defined for you in the challenge must remain outside of the function. You incorporated it into your function and that is why it is not passing.

Good luck.