The list starts with a single text item, “Initial”, and then I repeat the addition of the text “Repeat” four times. What I expect to end up with is a five-item list:
This reminds me of the need to re-instantiate a Dictionary every time you change or add to it.
Maybe add a new “Make List” / “save to variable” action after the Toolbox Pro one? (I can’t actually check what that action should be right now, as the latest beta has literally removed all of my possible Shortcut actions except for Siri Suggestions… )
It’s doing that because you take the initial list four times and add repeat to it to effectively create four lists each containing two entries; which the app will then simply treat as. single list of eight items.
If you want to append to a single list, you need to put the resulting list somewhere each time. You need to set it within the loop rather than just generating a value in the loop.
Note the result of adding to the list is a new list … not nothing with the old list having been updated. That’s where we can come back to using non-magic variables. Not everything can be magical.
That’s definitely what it’s doing, but I wouldn’t have guessed it from the action’s description. Thinking about it more carefully, though, it does make sense that you can’t change a magic variable. I have a feeling ‘Add To List‘ wasn’t built with the idea of using it in a loop, because it creates a new list with every pass.
It works the same way as the native add to variable and add to dictionary actions. It is just how the ‘Shortcuts language’ works - things you might do horizontally in a single line in other languages you have to do vertically in Shortcuts as the outputs of operations are passed down rather than across.