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).
The Challenge
Like the initial challenges we worked on some pytests so you can verify your regexes, so the steps would be:
-
If you don’t have pytest installed make a virtual env and pip install pytest
-
Open
test_regex.py
and read the tests. -
Open
regex.py
and check the docstrings. -
Now it’s time to get those regexes in! Start adding them to the functions in
regex.py
. -
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!
Bonus
Ideally we reach 10 regexes for this challenge so if you want to contribute 4 more regex exercises, just edit regex.py
and 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).
By the way, on our regex tag I saw we featured RegexTip quite a bit in our weekly Twitter digests, so maybe that’s an interesting account to follow if you want to learn more about Regexes.
Slack Channel
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.
Credit
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.
About
Our goal is to learn and teach you Python through practical exercises. Learning a programming language is way more fun as a community!
For any feedback, issues or ideas use GH Issues, tweet us or drop us an email.
Keep Calm and Code in Python!
— PyBites