Apply material to an object with Python Script

Hi everyone,

I’m new in Blender and Python. I’m simply trying to apply an existing material to an existing object with Python by using the object name and material name. Could you help me please ?

I’m using Blender 2.92

Have a nice day !

I found how to do it :

bpy.data.objects['objectName'].data.materials.append(bpy.data.materials.get('materialName'))