Randomly mix the order of lines in a file
python
Solution
The `random` module is your friend:
import random
with open("infile.txt") as f:
lines = f.readlines()
random.shuffle(lines)
with open("outfile.txt", "w") as f:
f.writelines(lines)
should do.
Problem
Suppose I have a file containing some lines: ``` line 1 ... line 2 ... ... line n ... ``` Is it possible to have another file where the order of the lines will be randomly mixed ?