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 Python Dates and Times Date and Time Basics strptime and strftime

Doug Devitre
Doug Devitre
16,516 Points

Quiz Question Python Dates and Times - parse from data to string

Please fill in the correct answer in each blank provided below.

Complete this line of code by entering the correct format string

dt = datetime.strptime('Mon 11 Dec 2023, 11:34PM','____')

Here is what I put in the empty space %b %d %b %Y, %I:%M%p

I received an error and not sure what I missed.

Here are the codes. https://strftime.org/

Any ideas?

2 Answers

Steven Parker
Steven Parker
231,268 Points

You're close, but the first code (for the abbreviated weekday) should be %a instead of %b.

You correctly used %b for the abbreviated month later on.

Doug Devitre
Doug Devitre
16,516 Points

Clear, concise, and to the point. Thanks again, Steven Parker!