9
Just learned how much time while loops save in Python
I was working on a little script to clean up some file names over the weekend. I had a bunch of 'if' statements checking each file one by one, and it got messy fast. Then I found out about while loops in a tutorial by Corey Schafer. Now I can loop through hundreds of files with just 4 lines of code. Has anyone else had a moment where one simple concept made a whole project click?
2 comments
Log in to join the discussion
Log In2 Comments
aaron8841mo ago
Wait till you get into list comprehensions, then you can do that whole while loop thing in a single line. That really blew my mind the first time I saw it.
4
dylanmurray1mo ago
It's like finding the right tool in a jammed drawer... everything just slides open after that.
2