# Breaking/continuing out of multiple loops

**URL:** <https://discuss.python.org/t/breaking-continuing-out-of-multiple-loops/18354>\
**Category:** Ideas\
**Created:** [August 21, 2022, 6:43am UTC](https://discuss.python.org/t/breaking-continuing-out-of-multiple-loops/18354 "2022-08-21T06:43:50Z")\
**Posts on this page:** 1\
**Showing post:** 33

<div class="post-metadata">

**Author:** ![Gouvernathor](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/gouvernathor/32/7957_2.png) [@Gouvernathor](https://discuss.python.org/u/Gouvernathor)\
**Post date:** [August 29, 2022, 12:00am UTC](https://discuss.python.org/t/breaking-continuing-out-of-multiple-loops/18354/33 "2022-08-29T00:00:30Z")

</div>

@Rosuav No. You could have a good name to give the function if you _had_ to, yet believe that code understandability alone doesn’t make it necessary or relevent to separate the function from the rest. In such a situation, a function like select\_which\_moon\_or\_satellite\_to\_go\_to would only be defined because the syntax gives no other choice. Even though we have a good name available for it.  
And the more I think about it the more I come to disagree with the concession I made in my previous message : if you want to name a code snippet that you only use once, you should probably just put a comment before it. I’m not judging anyone’s practices, but _I personally_ would probably never define a function just for that.

If you want more context for the example I imagined just then, say I want to select a moon from several star systems :

```nohighlight
for system in systems:
    for planet in system:
        for moon in planet.moons:
            if moon.has_no_titanium:
                break 2 # I don't want to be in a system with a moon with no titanium
            if moon.has_atmosphere:
                break # I don't want to be in the same planetary system

```

---

_[View the full topic](https://discuss.python.org/t/breaking-continuing-out-of-multiple-loops/18354)._
