I'm trying to randomise a list made up of lines from a text file in python, and random.shuffle() isn't working

21 Views Asked by At

My code is thus:

import random

with open(Te, 'r') as f:
    Terms = [line.strip() for line in f]
    #Takes lines of text from a file
           
with open(De, 'r') as e:
    Def = [line.strip() for line in e]
    #Takes lines of text from a file

Terms = random.shuffle(Terms)
Def = random.shuffle(Def)

However, when I try to output the shuffled lists, the output is just None, while when I output the un-shuffled list the output contains the lines of text in the text file. Am I using the shuffle function incorrectly, or is there a limitation to the shuffle function that I am unaware of?

0

There are 0 best solutions below