While this test script doesn’t really give any basis for actually comparing the For Loop to the While Loop, it does help us with understanding that their are situations that the For Loop is much faster.
There are so many factors that can come into play when you’re comparing these two in-built functions though. One is the compiler in your computer, the execution speed can change randomly based on what programmes your computer is running.
But also as a reminder, this video was more of a curiosity. Don’t waste time on trying to save a few milliseconds by deciding which loop you should use. Just make sure you use For Loops for fixed iterations, and While Loops for potentially infinite iterations.
☞ Python Tutorials for Beginners - Learn Python Online
☞ Learn Python in 12 Hours | Python Tutorial For Beginners
☞ Complete Python Tutorial for Beginners (2019)
☞ Python Programming Tutorial | Full Python Course for Beginners 2019