I am a starter of Python and pretty interested in scripting with Python.
Recently, I faced a situation that I need to obtain all integer combination in the range of [-10, +10] and put them into two arrays in order, which means I have arrays [A] and [B], in [A], I need to have the first element to be [-10], the second [-10], and then in [B] it is [-10,-10], then I will erase the elements and make [A] have [-10,-10] but [B] have [-10, -9], then the next one is [A] = [-10,-10], [B] = [-10,-8]... until the last one [A] = [10,10], [B] = [10,10]. So I made 4-layer for loop to achieve that:
import numpy as np
A = np.zeros((1,2))
B = np.zeros((1,2))
for i in range(-10,+10+1):
A[0][0] = I
for ii in range(-10,+10+1):
A[0][1] = ii
for iii in range(-10,+10+1):
B[0][0] = iii
for iV in range(-10,+10+1):
B[0][1] = iV
It works well to generate [A] and [B] in order in a stupid way. However, if I would like to change the size of [A] and [B], like A = np.zeros((1,3)), what should I do instead of adding more for loop lines? Is there a function to control the for loop numbers with different layers?
Thank you so much. Hope I have made my question clear LOL.
Best
Enxiao