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 trialRon Tovbin
Python Web Development Techdegree Student 6,268 PointsGetting stuck here
Any help here would be appreciated.
import re
string = '1234567890'
good_numbers = re.findall(r"""
\d+
[^5678]+
""",string,re.X)
2 Answers
David Deberry
5,447 PointsHey I searched and found this as an answer. Do not upvote my answer because sadly it is not my code so I do not deserve it lol But I hope this helps.
good_numbers = re.findall(r'\d[,9][^567]', string)
Iain Simmons
Treehouse Moderator 32,305 PointsI think you might be overcomplicating thingsβ¦
Just use the negated character class ([^notme]
). You don't need any modifiers.
Also, I think the range of characters you're not meant to include is wrong. Your code has 5678
, but it should only be 567
.
Let us know how it goes!