do not use too many nested loops and conditions

This page is not yet available in Spanish. We are working on its translation.
If you have any questions or feedback about our current translation project, feel free to reach out to us!

Metadata

ID: python-best-practices/too-many-while

Language: Python

Severity: Warning

Category: Best Practices

Description

A program should have a maximum level of nesting loops. If your program has too many nested loops (if/for/while), consider refactoring your program to avoid too many nesting levels.

Non-Compliant Code Examples

while bla:
    while foo:
        while bar:
            while baz:
                pass

Compliant Code Examples

while bla:
    while foo:
        while bar:
            pass
https://static.datadoghq.com/static/images/logos/github_avatar.svg https://static.datadoghq.com/static/images/logos/vscode_avatar.svg jetbrains

Seamless integrations. Try Datadog Code Analysis