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![](https://ecs-static.teamtreehouse.com/assets/views/marketing/shared/community-banner-white-47072046c51352fe6a69f5e691ff5700b28bb11d45197d7bdf066d9ea3f72d0c.webp)
![Andy McDonald](https://secure.gravatar.com/avatar/2c7a70bb997cb62e77a9341481bf2b27?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Andy McDonald
Python Development Techdegree Graduate 13,801 PointsStrptime 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.remove(dude[1])
dude.insert(1, newb)
blist.remove(blist[bcount])
blist.insert(bcount, dude)
bcount += 1
print(blist)
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.
1 Answer
![hannahgibson2](https://uploads.teamtreehouse.com/production/profile-photos/855672/micro_Screen_Shot_2014-05-08_at_10.16.17_AM.png)
hannahgibson2
30,777 PointsIf "dude" is a string, then "dude[1]" would be a single character which wouldn't match the date time formatting, right?
Steven Parker
230,688 PointsSteven Parker
230,688 PointsCode 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.