How can I use for loop (or while loop) in python to move 50 objects with random beginning positions to specific positions
This script creates random points and mixes with points of helix. Here i used lerp() from mathutils to mix two points based on frame. You can replace helix points with vertices of cylinder.
import bpy
from random import randint
from mathutils import Vector
from math import sin, cos, pi

# create helix points
def helix(amount, radius, height, twist):
    points = []
    for i in range(amount):
        t = twist * 2 * pi * i/amount
        x = radius * sin(t)
        y = radius * cos(t)
        z = height * radius * t / amount
        points.append(Vector((x,y,z)))
    return points

# generate random points
def random_points(amount, min, max):
    randpoints = []
    for i in range(amount):
        x = randint(min, max)
        y = randint(min, max)
        z = randint(min, max)
        randpoints.append(Vector((x, y, z)))
    return randpoints
 
random_points = random_points(50, -3, 3)
final_points = helix(50, 0.2, 8, 8)

# get objects from collection
coll = bpy.data.collections.get(&quot;spheres&quot;)
objects = coll.objects

# clear previous animation data
for obj in objects:
    obj.animation_data_clear()
        
start = 1
end = 100
for f in range(start, end+1):    
    bpy.context.scene.frame_set(f)
    for i, obj in enumerate(objects):
        obj.scale = (0.1,0.1,0.1)
        obj.location = random_points[i].lerp(final_points[i], f/end) # vector1.lerp(vector2, factor)
        obj.keyframe_insert(&quot;location&quot;, frame = f) # insert location keyframe