Exactly like you wrote it but with proper spacing in front
Code:
i = group.waypoints.iterator ()
for waypoint in i:
# 400 * 1852 is 400 NM in meters.
if waypoint.length > 400*1852:
zigZagToWaypoint(waypoint,i,20,4.5)
Then just paste that in group change, rather than group condition (you can leave that empty).
Edit: Also just a suggestion from playing a patrol with zig-zagging convoys: 4.5nm might be too short, the AI isn't very good at turning in formation.