Python Functional Python Functional Workhorses attrgetter

Cross Ender
Cross Ender
9,564 Points

This is not working...?

I just re-watched the video and used the same techniques, but it's not working.

sorting.py
import datetime
from operator import attrgetter

date_list = [
    datetime.datetime(2015, 4, 29, 10, 15, 39),
    datetime.datetime(2006, 8, 15, 14, 59, 2),
    datetime.datetime(1981, 5, 16, 2, 10, 42),
    datetime.datetime(2012, 8, 9, 14, 59, 2),
]

sorted_dates = sorted(date_list, key=atrrgetter('day'))

1 Answer

Dave Harker
PRO
Dave Harker
Pro Student 15,049 Points

Hi Cross Ender,

You've got a typo :smile: easy to make them!!

change

sorted_dates = sorted(date_list, key=atrrgetter('day'))

to

sorted_dates = sorted(date_list, key=attrgetter('day'))

Nice work though, keep going!
Happy coding,
Dave :dizzy: