title: Change the color of a grid of cubes in Blender
body: <p>I create the faces of a cubic prism using the following function:</p>
  <pre><code>def SideXY(data):
      grid_dictionary=[]
      material_dictionary=[]
      position_x=0
      bpy.ops.object.select_all(action='SELECT')
      bpy.ops.object.delete(use_global=False, confirm=False)
      flag=bool(0)
      for x in range (0,length):
          position_x += 1
          position_z = 0
          for z in range (0,height):
              position_z += 1
              bpy.ops.mesh.primitive_uv_sphere_add(radius=0.5, enter_editmode=False, location= 
      (position_x, 0, position_z))
              material = bpy.data.materials.new(&quot;test&quot;)
              tmp=np.array([position_x,0,position_z])
              for i in range(len(data)):
                  if data[i][0] == tmp[0] and data[i][1] == tmp[1]:
                      flag=1
              if flag==1:
                  material.diffuse_color = (1, 1, 1, 1)
              else:
                  material.diffuse_color = (1, 0, 0, 1)
                  
  
              
                          
              bpy.ops.mesh.primitive_uv_sphere_add(radius=0.5, enter_editmode=False, location= 
      (0, position_x, position_z))
              material = bpy.data.materials.new(&quot;test&quot;)
              tmp=np.array([position_x,position_z,0])
              for i in range(len(data)):
                  if data[i][0] == tmp[0] and data[i][1] == tmp[1]:
                      flag=1
              if flag==1:
                  material.diffuse_color = (1, 1, 1, 1)
              else:
                  material.diffuse_color = (1, 0, 0, 1)
                  
  
    
      data=np.array([[1,1], [2,2]])
      SideXY(data)
      data2=np.array([[3,2],[1,1]])
      SideXY(data2)
  </code></pre>
  <p>Yet, my ultimate goal is to have certain points of the grid coloured differently. My goal, however, is not achieved . Excuse me if the question is trivial. I have been working on blender only for 1 day. Thank you in advance</p>