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.
Is there a way to check my work against the answer key in the challenges?
I have something wrong in my code below and it would be nice to be able to check against the answer key so I can learn from it if I cannot figure it out.
import re def first_number(string): re.search(r'\d', string) return 'string'
Daniel Medina13,863 Points
You are very close with what you have.
Right now you are returning 'string.' You'll need to move your return statement so that you're returning what you're searching for in your regex.
Regarding your question on answer keys:
I think a great workaround would be to open the Python shell in Treehouse workspaces and type your code out in there. By print()'ing out your code in certain areas, you can double check what your input is with what's being expected by the challenge. This gives you immediate feedback without the need for any external software.
Another solution is to type the code out locally in your favorite IDE (e.g. VS Code, PyCharm Community Edition, Thonny), set up breakpoints, and step through the code. Observe how variables and their values change. See which, if any, conditions are affecting them.
This process can be daunting especially if it is new material, but once you get started with it, it is a powerful way to debug your code and pinpoint errors.
Much thanks for the help-that worked!
Will plan on doing that going forward, great tip.