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.
Why does this exclude not work? It keeps returning 7 with it.
It keeps returning 7 when I have expressed to leave it out.
import re string = '1234567890' good_numbers = re.findall(r'\d[^567]', string)
Dan Johnson40,532 Points
Since you have a \d in your regular expression along with the character set [^567] you're saying, "capture any one digit, and then any character that is not 5, 6, or 7." This is why you can end up with one number that falls in the excluded character set.
So all you need to do is remove the \d and you should capture the correct groups.