S
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?
1 comments

Log in to join the discussion

Log In
1 Comment
aaron884
aaron88425m 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