Checking enemy's troop size

Hello. Is there a way of checking the total number of enemies in a troop during battle? For example: through a script call.

Thanks in advance
Code:
$game_variables[x] = $game_troop.members.size

Replace x with a variable of your choice. If you want to interact with this, remember that some parts of the engine count the first member as member 0 (so a troop with 8 enemies would actually mean that the 7th is the last), so for those cases you may want to reduce the value by 1 before doing anything. I found that out the hard way.
Code:
$game_variables[x] = $game_troop.members.size

Replace x with a variable of your choice. If you want to interact with this, remember that some parts of the engine count the first member as member 0 (so a troop with 8 enemies would actually mean that the 7th is the last), so for those cases you may want to reduce the value by 1 before doing anything. I found that out the hard way.
Thank you!

Original thread: https://forums.rpgmakerweb.com/threads/checking-enemys-troop-size.147901/