Customizing within subplots depend the data

I would please like suggestions for how to load image by customizing within subplots. Here is my code:

load_data = mars['photos']

fig = plt.figure()

for idx, k in zip(range(len(load_data)), load_data):
    ax = fig.add_subplot(n ,2, idx+1)    
    response = io.imread(load_data[idx]['img_src'])
    im = ax.imshow(response)
    name = load_data[idx]['camera']['full_name']
    ax.set_title(f'{name}')
    ax.set_axis_off()

fig.tight_layout()

But the error value from add_subplot always appears.

ValueError: num must be 1 <= num <= 8, not 9

I also want the row in the subplot to be based on the length of data that is divided by 2 columns. I want to like this below, and the rows will continue to be based on data.

enter image description here