How to model 4 camera automatically in python import bpy
import numpy
import math
import os
from mathutils import Euler
from bpy import context, data, ops
    
scene = bpy.context.scene
bpy.ops.object.select_all(action = 'SELECT')
bpy.ops.object.delete(use_global = False, confirm = False)


#***********************Camera parameters**********************************
focal    = 3.04  #focal lenght (mm)
sw       = 3.68  #sensor width (mm)
sh       = 2.76  #sensor height (mm)
eul_mode ='XYZ'


number_cam = 4
count      = 1

location = [(0, 0, 3), (3, 0, 3), (0, 3, 3), (0, -3, 3)]
rotation = [(math.radians(0), math.radians(0), math.radians(0)), (math.radians(45), math.radians(0), math.radians(90)), (math.radians(45), math.radians(0), math.radians(180)), (math.radians(45), math.radians(0), math.radians(0))]

if count &lt;= number_cam:
    for cam in scene.objects:
        cam_name = 'Camera' + str(count)
        cam      = bpy.data.cameras.new(name = cam_name)
        cam.lens = focal
        cam.sensor_width  = sw
        cam.sensor_height = sh

        cam_obj                = bpy.data.objects.new(cam_name, [cam + str(count)])
        cam_obj.rotation_mode  = eul_mode
        cam_obj.location       = location[count]
        cam_obj.rotation_euler = math.radians(rotation[count])
        scn.collection.objects.link(cam_obj)
        
count = count + 1

I am a beginner in python with Blender.
I would like to create 4 cameras automatically with Python but I have an error in this code.
Can you tell me what this error is and if what I want to do is possible?
Thanks a lot
Some fixes.

Lose the &quot;bling&quot; ... many moons ago a language named COBOL was
nicely aligned on equals signs, would stick with pep8 for python. The
result below is result of autopep8 via nvim text editor.
Never a fan of scripts that delete everything first, took that out,
it was an issue with your original logic, since the scene now had no
objects.
Made one loop to add each camera. Named via fstring formatting rather than string addition (which can be slow).

Resultant script.
import bpy
from math import radians
from bpy import context, data

scene = context.scene

#***********************Camera parameters************************
focal = 3.04  #focal lenght (mm)
sw = 3.68  #sensor width (mm)
sh = 2.76  #sensor height (mm)
eul_mode = 'XYZ'

number_cam = 4

location = [(0, 0, 3), (3, 0, 3), (0, 3, 3), (0, -3, 3)]
rotation = [(radians(0), radians(0), radians(0)),
            (radians(45), radians(0), radians(90)),
            (radians(45), radians(0), radians(180)),
            (radians(45), radians(0), radians(0))]

for count in range(number_cam):
   cam_name = f'Camera{count}'
   cam = bpy.data.cameras.new(name=cam_name)
   cam.lens = focal
   cam.sensor_width = sw
   cam.sensor_height = sh

   cam_obj = bpy.data.objects.new(cam_name, cam)
   cam_obj.rotation_mode = eul_mode
   cam_obj.location = location[count]
   cam_obj.rotation_euler = rotation[count]
   scene.collection.objects.link(cam_obj)