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.

Tomer Inbar
2,248 PointsPython TZ challenge
Challenge: Create a new timezone for US/Pacific, which is 8 hours behind UTC (UTC-08:00). Then make a new variable named hill_valley that is naive with its tzinfo attribute replaced with the US/Pacific timezone you made.
seems like, I didn't understand what I have been asked. my code is:
import datetime
pacific = datetime.timezone(datetime.timedelta(hours=-8))
hill_valley = datetime.datetime(2015, 10, 21, 4, 29,).replace(tzinfo = pacific)
What am I missing?
[MOD: added ```python markdown formatting -cf]
2 Answers

Chris Freeman
Treehouse Moderator 68,094 PointsYour code passed for me. There are two ways to create hill_valley:
import datetime
naive = datetime.datetime(2015, 10, 21, 4, 29)
pacific = datetime.timezone(datetime.timedelta(hours=-8))
# apply 'replace' to the "naive" datetime
hill_valley = naive.replace(tzinfo = pacific)
Though, creating a new datetime
object also passes the Task 1:
# apply 'replace' to a new "naive" datetime:
hill_valley = datetime.datetime(2015, 10, 21, 4, 29).replace(tzinfo = pacific)
I did notice a trailing comma after the "29" in your code, but this shouldn't break anything.
Was there some other question?

Peter Rzepka
4,118 Pointsnaive = datetime.datetime(2015, 10, 21, 4, 29)
#define Pacific variable
pacific = datetime.timezone(datetime.timedelta(hours=-8))
#set hill_valley variable tzinfo to your new pacific with same time as naive
hill_valley = datetime.datetime(2015, 10, 21, 4, 29, tzinfo=pacific)
Tomer Inbar
2,248 PointsTomer Inbar
2,248 PointsThanks for the quick response! Have no idea why mine didn't pass.