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 trialBakang Elliot Simane
5,119 Pointsi am stuck here
i cant figure this one out
import datetime
birthdays = [
datetime.datetime(2012, 4, 29),
datetime.datetime(2006, 8, 9),
datetime.datetime(1978, 5, 16),
datetime.datetime(1981, 8, 15),
datetime.datetime(2001, 7, 4),
datetime.datetime(1999, 12, 30)
]
today = datetime.datetime.today()
def is_over_13(dt):
def date_string(dt): return dt.strftime("%B %d")
birth_dates = map(date_string, filter(is_over_13, birthdays))
1 Answer
adrian miranda
13,561 PointsYou will probably do better if you actually include the question that has you stumped, as well as what happens when you try it.
You have part of the is_over_13 question, but not all of it, is that where you are having trouble?
You can find the difference between two dates with subtraction
ddiff = today - whenever
And you can find the number of days in that difference by looking at the days attribute
# Here are the number of days
ddiff.days
And now all you should need to do is compare that to the number of days in 13 years, and return True or False depending on whether it is great or not.
If you are concerned by the last part, where you are supposed to combine your functions with map and filter, then I suggest you start by breaking it up. First use filter and date_string to filter only the birthdays that are 13 years or older.
Then feed the results of filter into map, and use the data_string function to format them properly.
Bakang Elliot Simane
5,119 PointsBakang Elliot Simane
5,119 PointsThis challenge seems to be hard for me all of that drains my brain cells so may if I can get how to solve it then I will figure out how it is done