It's not that I'm so smart, it's just that I stay with problems longer. - A. Einstein
Hi Pythonistas, it's beginning of the month so we're busy selecting some cool code challenges for you to work on to hone your Python skills. Regular Expressions was a long time coming so let's get it out there. We hope we hit a decent intermediate level with this challenge. If you have questions ask us in the comments or join our Slack (see further below).
If you don't have pytest installed make a virtual env and pip install pytest
test_regex.py and read the tests.
regex.py and check the docstrings.
Now it's time to get those regexes in! Start adding them to the functions in
You can run the tests at any time, when all done and good, they should pass:
$ pytest test_regex.py ... collected 6 items test_regex.py ...... === 6 passed in 0.04 seconds ===
We might give away too much linking to our regex article, but sure: if you're stuck checkout 10 Tips to Get More out of Your Regexes: we found inspiration there putting this challenge together.
However you learn the most if you really try it yourself first!
Ideally we reach 10 regexes for this challenge so if you want to contribute 4 more regex exercises, just edit
test_regex.py (yes please do provide tests) and open a PR, the challenge folder is here (email or comment the code is fine too).
For a beginner some of our challenges might be overwhelming. Another observation is that the process of doing these challenges is as interesting as the final result.
We are eager to expand our awesome PyBites community. For this reason we are opening up our private Slack for you to discuss our code challenges and let us know how you're progressing your Python skills. Send us an email if you want to join.
This way you get the unique opportunity to learn from other Pythonistas and share some of your own learning.
You can PR your work to our Community branch of our Challenges repo. We will include it in our review post. Our PR template also lets you reflect a bit on your learning and provide some feedback how we can keep our challenges interesting. See detailed instructions here.
Our goal is to learn and teach you Python through practical exercises. Learning a programming language is way more fun as a community!
Keep Calm and Code in Python!
Do you want to get 250+ concise and applicable Python tips in an ebook that will cost you less than 10 bucks (future updates included), check it out here.
"The discussions are succinct yet thorough enough to give you a solid grasp of the particular problem. I just wish I would have had this book when I started learning Python." - Daniel H
"Bob and Julian are the masters at aggregating these small snippets of code that can really make certain aspects of coding easier." - Jesse B
"This is now my favourite first Python go-to reference." - Anthony L
"Do you ever go on one of those cooking websites for a recipe and have to scroll for what feels like an eternity to get to the ingredients and the 4 steps the recipe actually takes? This is the opposite of that." - Sergio S