27
My Python script went from 15 lines to 3 after I learned about list comprehensions
I was rewriting a data filter from a tutorial in Denver and it just clicked. Has anyone else had a moment where a single concept cleaned up their code a ton?
2 comments
Log in to join the discussion
Log In2 Comments
ivancoleman1mo ago
Man, list comprehensions felt like cheating at first. I used to write whole loops just to build a simple list of squares. Now it's just [xx for x in range(10)] and I'm done. It completely changed how I clean up data from APIs. My old scripts look like a different person wrote them.
5