Stop using range() for loops in Python. Use enumerate() @DataScienceGarage
Stop using range() for loops in Python. Use enumerate()  @DataScienceGarage
Uploaded January 2020 | Updated September 2026, 2 weeks ago
With this video I explain why in many cases we should use enumerate() instead of range() function in Python for loops.

The way of using range() is ugly: You either need a separate variable assignment to get the element or use a[i] all the time which could theoretically be an expensive operation. The point is that you generally don't want to use range(len(l)) when you want to iterate the elements of a list (although there may still be cases where it makes sense).

I think than enumerate is much more flexible and readable Python coding option than len(l) with range().

Thank you for watching. See you on other tutorials.
Vytautas.

#pythonfunctions
#pythonloops
#pythonbegineers
Stop using range() for loops in Python. Use enumerate()AI project with Flask. Deployed Keras model - Google Cloud. Jupyter Notebook to Web applicationCreate Dummy (Categorical) Variables with Pandas in Python (No sklearn)Horoskopas 2016-iems (visi zodiako ženklai) (© Nuo iki - LNK)Efficient Critical Thinking in your Data Science Career | podcastAdam. Rmsprop. Momentum. Optimization Algorithm. - Principles in Deep LearningWarsaw Chopin - Vilnius int. airport (full flight: take off and landing)Fire hands | ADOBE AFTER EFFECTS result5 Habits & 5 Soft Skills for Data Scientist to get life easierUpload Pandas DataFrame to BigQuery and make SQL in Google Cloud ConsoleAWS Machine Learning Specialty Exam Readiness - Solving Domain Quizzes LiveHow to use Decorators in Python - Get Started Here!
Data Science Garage |

Stop using range() for loops in Python. Use enumerate()

SHARE TO X SHARE TO REDDIT SHARE TO FACEBOOK WALLPAPER