I signed up for this 7-day challenge to test my knowledge, and it’s been an absolute delight!
As a newbie, when I find myself on StackOverflow reading discussions about “the most Pythonic way” to do something, I usually feel a bit left out… I’ll just be happy if I can do it any darned way at all, never mind in the most Pythonic way possible! BUT the time is probably right to start moving on from that attitude :).
Colin Morris’ short, sharp challenge covers just 2 or 3 concepts each day, so I got a quick review of what I’d already learned. But the really great part was the exercises – only 5 or 6 each day, so again very manageable. They start off easy and work their way up to more challenging. You can test your solutions in place and get comments on how you did and why. Each exercise comes with a hint if you need help but are not ready to give up, and a solution so you can check how you did.
I feel like I really learned a lot from these exercises about how to code more elegantly and efficiently. For example, I would have done this before:
def is_valid_zip(zip_code): """Returns whether the input string is a valid (5 digit) zip code """ if zip_code.isdigit() == True: if len(zip_code) == 5: return True else: return False else: return False
That’s a lot of words, when just this will do!
def is_valid_zip(zip_code): """Returns whether the input string is a valid (5 digit) zip code """ return len(zip_code) == 5 and zip_code.isdigit()
There were numerous instances like this where I was challenged to achieve an objective in a new way, or using just one line of code! I became a lot more aware of making my code intelligible to others. And there were some instances where I was stumped and found the solutions was most illuminating. In all cases Colin does an amazing job of building up knowledge concept by concept, making sure you know WHY something is so, and reminding you how to help yourself in future when you’re stuck.
Highly recommended – loved it – thanks!