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 trial

Python Dates and Times in Python (2014) Where on Earth do Timezones Make Sense? Datetime Awareness

Why do I get an error "`paris` isn't a datetime." ? https://pastebin.com/akUjqjnV

This variable should be <class 'datetime.timezone'> and not datetime. If I run my code in python IDLE I get the correct output = 2015-10-21 13:29:00+01:00

aware.py
import datetime

naive = datetime.datetime(2015, 10, 21, 4, 29)
pacific = datetime.timezone(datetime.timedelta(hours=-8))
hill_valley = datetime.datetime(2015, 10, 21, 4, 29,tzinfo = pacific)


paris = datetime.timezone(datetime.timedelta(hours=1))

hill_valley.astimezone(paris)

2 Answers

Steven Parker
Steven Parker
229,644 Points

The instructions say "Make a new timezone that is UTC+01:00.", but they don't say that it must be stored in a variable or what to name it.

Then they say "Create a new variable named paris that uses your new timezone and the astimezone method to change hill_valley to the new timezone." So "paris" is expected to be a "datetime", as "hill_valley" is, but with a different timezone.

So while you've done all the steps, the final result doesn't get get assigned to "paris".

Thank you very much, Steven.