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
Malcolm Jury
11,194 PointsTask 2 of 2 - RegEx driving me nuts
I am stuck on the task where you have to give the function a number and a string, what am i doing wrong?
def numbers(count, myString): regTest = r"/w"*count return (numbers(regTest, myString))
3 Answers
Kenneth Love
Treehouse Guest Teacher/w isn't the escape sequence, \w is.
Mikael Enarsson
7,056 PointsI don't have the energy to go into details right now, but if you are interested ask, and I'll try to get back to you later:
def numbers(count, string): #get the number of consecutive numbers to search, and the
#string to search for it
return re.search(r'\d'*count, string) #Here, search count times any digits (\d being the escape
#sequence for numbers) in the string
Malcolm Jury
11,194 Pointsfacepalm