Companies Home Search Profile

How to Write Pythonic Loops

Focused View

Dan Bader

09:25

106 View
  • 1. How to Write Pythonic Loops Overview.mp4
    01:36
  • 2. Use range() or xrange() to Track Loop Index.mp4
    01:54
  • 3. Iterate Over a Container Directly.mp4
    01:45
  • 4. Use enumerate() to Keep a Running Index.mp4
    01:20
  • 5. Write a C-Style Loop With range() and Multiple Parameters.mp4
    01:37
  • 6. How to Write Pythonic Loops Conclusion.mp4
    01:13
  • Description


    One of the easiest ways to spot a developer who has a background in C-style languages and only recently picked up Python is to look at how they loop through a list. In this course, you’ll learn how to take a C-style (Java, PHP, C, C++) loop and turn it into the sort of loop a Python developer would write.

    You can use these techniques to refactor your existing Python for loops and while loops in order to make them easier to read and more maintainable. You’ll learn how to use Python’s range(), xrange(), and enumerate() built-ins to refactor your loops and how to avoid having to keep track of loop indexes manually.

    The main takeaways in this tutorial are that:

    Writing C-style loops in Python is considered not Pythonic. Avoid managing loop indexes and stop conditions manually if possible.

    Python’s for loops are really “for each” loops that can iterate over items from a container or sequence directly.

    What You'll Learn?


    • Writing C-style loops in Python is considered not Pythonic. Avoid managing loop indexes and stop conditions manually if possible.

    • Python’s for loops are really “for each” loops that can iterate over items from a container or sequence directly.

    More details


    User Reviews
    Rating
    0
    0
    0
    0
    0
    average 0
    Total votes0
    Focused display
    Category

    Dan Bader is the owner and editor in chief of Real Python and the main developer of the realpython.com learning platform. Dan has been writing code for more than 20 years and holds a master’s degree in computer science. He’s the author of Python Tricks, a best selling programming book for intermediate Python developers.

    Hey, I’m Dan Bader and I help Python developers take their coding skills and productivity to the next level. I’m an independent software engineer, author, and speaker. I’ve been writing code for more than two decades—and I’d love to help you become a more proficient Python coder.

    Here’s where you can find me elsewhere on the web:

    I’ve also done some podcast interviews and other media appearances you can check out:

    Learn Python online: Python tutorials for developers of all skill levels, Python books and courses, Python news, code examples, articles, and more.
    • language english
    • Training sessions 6
    • duration 09:25
    • English subtitles has
    • Release Date 2023/01/05