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 trialChase Svoboda
Python Development Techdegree Graduate 8,466 PointsThe Task is vague, and I'm not sure how my function takes in a timezone as a string
In creating my function, I created it to take in a string for the timezone, but there is nothing in the script that I can relay it back to. More than anything, I'm confused how to structure this code to fulfill the challenges parameters.
import datetime
import pytz
starter = pytz.utc.localize(datetime.datetime(2015, 10, 21, 23, 29))
name = "US/Pacific"
def to_timezone(name, local):
tmzn = pytz.timezone(name)
return local.astimezone(tmzn)
to_timezone(name, starter)
1 Answer
boi
14,242 PointsChase Saldate, listen brother, you're overthinking it, All you need is a single 4-inch line of code, that's it. Lemme give you some hints.
1) You don't need to write any code out of the function.
2) In the challenge notes, it says that the function to_timezone
will take a timezone name as a string, which means
that the function to_timezone
will have ONE argument parameter and the user calling the function will give a
timezone name as a string for example "US/Pacific" or "Asia/Calcutta" will be the string parameter.
3) So all you have to do is convert the starter
date-time variable, provided, into the timezone of the string
parameter.
If you're having trouble just msg me and I will help you an infinite amount of time no problem for me (Just make sure you send me 5$)
Chase Svoboda
Python Development Techdegree Graduate 8,466 PointsChase Svoboda
Python Development Techdegree Graduate 8,466 PointsHahaha I appreciate the banter! And thank you for the help! I think I needed to sleep on it, but your guidance turned a needless 20min frustration into a minute relief.