Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.
What's missing from this simple time_machine challenge?
Is the time variable starter supposed to be on the inside of the delorean function? To be before, I subtracted the hours passed in to decrease the starter time. When I try it in my workspace, the code runs as expected.
import datetime def delorean(before_start): starter = datetime.datetime(2015, 10, 21, 16, 29) print(starter) jumped = starter - datetime.timedelta(hours=before_start) print(jumped) return jumped jumped_started = delorean(4) print(jumped_started)
Clayton PerszykTreehouse Moderator 48,553 Points
import datetime starter = datetime.datetime(2015, 10, 21, 16, 29) # move this out of function def delorean(before_start): print(starter) jumped = starter + datetime.timedelta(hours=before_start) # + not - print(jumped) return jumped jumped_started = delorean(4) print(jumped_started)
Thank you Clayton. I had used the "-" instead of the "+" because I thought the question asked for before the start time.