How Does A Nested For Loop Work Python