What do you think about an "indent" command?

I am currently coding an RPG. I was working on the enemy attack system, and there were 2+ enemies. I was trying to see if there was a purely organizational-purpose command to create a valid indent. Apparently, there isn’t.

So, I was thinking the indent command, if added, would work like this:

indent()
    # enemy 1
    attack = random.randint(1, 3)
    if attack == 1:
        # attack code

indent()
    # enemy 2
    attack = random.randint(1, 3)
    if attack == 2:
        # attack code

Or you could use it for something like that.

As an optional, separate feature related to this idea: inside the parentheses, you could type either "global" or "local", which could control the scope of variables inside the indent block.

If you do global:

example = 1

indent(global)
    print(example)
    # This will work, because you selected global.

If you do local:

example = 1

indent(local)
    print(example)
    # This will NOT work, because it was set to local,
    # and "example" was not defined in the indent block.

The main purpose of the indent command would be organizational: allowing programmers to create visually separated, properly indented sections of code without needing the indentation to represent a conventional Python control structure. The global/local feature would be an optional related addition rather than the main purpose of the command.
if the global/local feature were to be added, if there were no text in the parentheses, it would act like if you did indent(global).

If you really need a block, you can always do if True:. Though I think you’ll find that in practice, people are more likely to look for ways to eliminate indents rather than to add them.

For your enemy attack example, you would much likely be better off creating an attack function.

def try_attack(enemy_number):
    attack = random.randint(1, 3)
    if attack == enemy_number:
        ... # attack code

# enemy 1
try_attack(1)
# enemy 2
try_attack(2)

I don’t think that pure indent is a reasonable concept for structuring. No offense meant, but I rather suspect that the desire for stronger grouping comes from inexperience to use other established mechanisms for structuring. I’ll list a few different ways how to organize the code, and relatedly think about your problem.

In a plain code sequence we can use blank lines and comments for structuring

# enemy 1
attack = random.randint(1, 3)
if attack == 1:
    # attack code

# enemy 2
attack = random.randint(1, 3)
if attack == 2:
    # attack code

That’s ok, readable and established practice. If it get’s too long, it’s very likely that the code contains underlying logic structure. That can be extracted in a function, which gives it a name and defined inptus and outputs. It may even be that the concept can be applied multiple times. - This is the case explained by @duncathan above.

You might also want to encapsulate data and related functionality into classes, which could look like this:

class Warrior:
   def __init__(self, health):
       self.health = health

   def attack_enemy(enemies: list[Warrior]):
       """Attack a random enemy."""
       enemy = random.choice(enemies)
       # attack code - reduce self.health and/or enemy.health
       
enemy_healths = [5, 7, 6]
enemies = [Warrior(health) for health in enemy healths]

hero = Warrior(health=10)
hero.attack_enemy(enemies)

For academic interest, I believe the closet thing to a non-functional indent would be a no-op context manager - under the assumtion you don’t want any namespacing and if True: is too ulgy. This technically works, but I would strongly discourage using it:

import contextlib

@contextlib.contextmanager
def indent():
    yield

a = 1

with indent():
    b = 2

with indent():
   print(a + b)