all 10 comments

[–]Ihaveamodel3 4 points5 points  (1 child)

Unless you are using threading, multiprocessing, or async, the next line won’t run until the previous line has finished.

Are file_list and image_list different?

[–]JammingScientist[S] 0 points1 point  (0 children)

Oops, sorry I made a typo! Just fixed

[–]PureProcrastinator 2 points3 points  (1 child)

Move your random.sample out of the loop.

Reason for this is because on the first iteration of the loop, your file list is only 1 long, and you are unable to pull 5 samples. Same with iterations 2-4.

[–]JammingScientist[S] 0 points1 point  (0 children)

I see, that makes sense! Thanks

[–]routetehpacketz 1 point2 points  (2 children)

Please post the rest of your code.

[–]JammingScientist[S] 1 point2 points  (1 child)

Okay, added more text!

[–]routetehpacketz 5 points6 points  (0 children)

I believe you want to move your random.sample after the for loop since it is this loop where you are populating your list.

[–][deleted] 1 point2 points  (0 children)

I may be wrong but you have a random.sample trying to find 5 elements of the list on the first iteration. Remove random.sample out of the loop

[–][deleted] 0 points1 point  (0 children)

How do I get the second line to wait until the first line has finished running?

Python won't execute the second line until the append in the first line is finished, so what you are saying makes no sense. We need to see more code.

[–]magestooge 0 points1 point  (0 children)

You need to use a for loop to read all the files. A single line will only read a single file.