Python script help - assign certain materials to some particular objects
Using get(name) and startswith(...)

Using the get method of a collection, objects and materials in this case,  if an object doesn't exist with  name it returns None which is boolean false.  

Here I've made a helper method, and added a call to add default material "Material" to default cube object "Cube" or any name other starting with it, eg "Cube.001", but not "BigCube"

Taken a punt that you are looking for objects that start with those names, for which startswith is ideal. 

import bpy

def assign_mat(ob_name, mat_name):
    mat = bpy.data.materials.get(mat_name)
    obs = [o for o in bpy.data.objects if o.name.startswith(ob_name)]
    for ob in obs:
        if mat:
            ob.data.materials[0] = mat
    return obs and mat


if assign_mat("Cube", "Material"):
    print("assigned Material to Cube[*]")


Recommend something like

pairs = (("Cube", "Material"),
         ("Blob", "BlobMaterial.001"),
         ("Cone", "Material"),
        )

for ob_name, mat_name in pairs:
    assign_mat(ob_name, mat_name)


If nothing is assigned

if not any(assign_mat(ob_name, mat_name) for ob_name, mat_name in pairs):
    print("Assigned Nothing????")