4
Just realized Python's enumerate() saves me from writing ugly counter variables
Last week I was looping through a list and kept messing up my index variable, then a buddy showed me enumerate() and it cleaned up like 15 lines of code. Anybody else got a built-in function they ignored for way too long?
2 comments
Log in to join the discussion
Log In2 Comments
rowan2622d ago
zip() was that function for me. I spent way too long manually pairing up lists with indexes before someone showed me how to just zip them together. It makes working with multiple lists feel a lot cleaner.
4
miller.eva1d ago
My old mentor used to call zip() "the list marriage function" and every time I use it I still think of him standing at the whiteboard drawing little arrows between index positions... he was a weird guy but he knew his Python stuff.
8