There are different techniques or tools for different purposes:
- if-clause for a condition
- for loop for a list
- nested for-loop for a grid (2D array)
- triple for-loop for a cube (3D array)
- recursion for tree structures. E.g. when you search a file in a folder which has subfolders and each of the sub-folders has files and folders in turn. This is a tree.
Here is an example of recursion for art: Need clarification on how this piece of found code is working (recursion) - #4 by Chrisir
Chrisir