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 trialDhruv Ghulati
1,582 Points'NoneType' object has no attribute 'group'
Any idea why this is doing this?
import re
def first_number(i):
return re.match(r'\d',i)
2 Answers
Robert Richey
Courses Plus Student 16,352 PointsHi Dhruv,
The challenge is expecting a search, instead of a match.
The function should search, with a regular expression, the first number in the string and return the match object.
Kind Regards
Dhruv Ghulati
1,582 PointsI even tried
def first_number(i):
return re.search(r'/d',i)
And get the same error, which makes me think that it is something to do with the object i. If I put i=str() before my return, I get the same error though...
Robert Richey
Courses Plus Student 16,352 PointsIn your first post, the d was being escaped correctly, with a backslash - now you're using a forward slash, so the program is now looking for the literal string '/d' instead of a number.