C2W2 Programming assignment - split_data function not passing Coursera tests

Dear Community,
I am having troubles with the split_data function in C2W2 programming assignment.

Here is my code:

START CODE HERE

files = os.listdir(SOURCE_DIR)

Check if the files have zero length

for file in files:
file_path = os.path.join(SOURCE_DIR, file)
if os.path.getsize(file_path) == 0:
print(f"filename {file} is zero length, so ignoring.")
files.remove(file)

Randomize the files

import random
random.sample(files, len(files))

Split the files into training and validation sets

training_files = files[:int(len(files) * split_size)]
validation_files = files[int(len(files) * split_size):]

Copy the training files to the training directory

for file in training_files:
source_file_path = os.path.join(SOURCE_DIR, file)
destination_file_path = os.path.join(TRAINING_DIR, file)
shutil.copyfile(source_file_path, destination_file_path)

Copy the validation files to the validation directory

for file in validation_files:
source_file_path = os.path.join(SOURCE_DIR, file)
destination_file_path = os.path.join(VALIDATION_DIR, file)
shutil.copyfile(source_file_path, destination_file_path)

It works perfectly well and gives me exactly the same Expected outcomes as shown in the notebook. Yet I am receing the following feedback from Coursera grader:
Details of failed tests for split_data

Failed test case: failed to omit zero-length image. Tested with 6 images (one of zero length).
Expected:
5 files copied,
but got:
4.

Failed test case: incorrect number of training images when using split of 1.0 and a total of 123 images.
Expected:
123,
but got:
110.

Failed test case: incorrect number of training images when using split of 0.5 and a total of 123 images.
Expected:
a value close to 61 with absolute tolerance of +/- 1,
but got:
110.

Failed test case: incorrect number of validation images when using split of 0.5 and a total of 123 images.
Expected:
a value close to 61 with absolute tolerance of +/- 1,
but got:
13.

Failed test case: incorrect number of (training, validation) images when using a split of 0.5 and 12 images (6 are zero-sized).
Expected:
(3, 3),
but got:
(8, 1).

Although i passed the assignment, i have spent hours on trying to figure out why I lost points on this. Grateful if anyone could help me spot my mistake.
Thank you!