Is it bad to use nested for loops?
Nested loops are frequently (but not always) bad practice, because they're frequently (but not always) overkill for what you're trying to do. In many cases, there's a much faster and less wasteful way to accomplish the goal you're trying to achieve.
Can you avoid nested loops?
Avoid nested loops with itertools.
There is also a way to avoid nested loops by itertools. product() . You can use itertools. product() to get all combinations of multiple lists in one loop, and you can get the same result as nested loops.