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.

Python The Problem: For Loops

Andy McDonald
Andy McDonald
Python Development Techdegree Student 6,118 Points

Strptime says its getting a datetime when im giving it a string

Here's the problematic section of the code: ''' import datetime

BIRTHDAYS = ( ("James", "9/8", True, 9), ("Shawna", "12/6", True, 22), ("Amaya", "28/2", False, 8), ("Kamal", "29/4", True, 19), ("Sam", "16/7", False, 22), ("Xan", "14/3", False, 34), )

another block of code exists that puts a zero at any single digit day for each birthday.

for dude in blist: splitbday = dude[1].split('/')

if len(splitbday[1]) < 2:
    cday = '0' + splitbday[1]
    newb = splitbday[0] + '/' + cday
    dude.insert(1, newb)
    blist.insert(bcount, dude)
    bcount += 1


dblist = []

for dude in blist: print(dude) dbtime = datetime.datetime.strptime(dude[1], '%d/%m') print(dude[1]) ddude = dude ddude[1] = dbtime print(ddude) dblist.append(ddude) ''' It keeps saying that strptime requires a string but when I print "dude" it is clearly a string. I dont know what to do. Doesn't seem to make sense.

Steven Parker
Steven Parker
217,443 Points

Code should be complete and properly formatted. Take a look at these videos about Posting a Question, using Markdown formatting to preserve the code's appearance, and particularly this one about sharing a snapshot of your workspace.