I have a function which reads a list of items from a file. How can I select only 50 items from the list randomly to write to another file?

def randomizer(input, output='random.txt'):
    query = open(input).read().split()
    out_file = open(output, 'w')
    
    random.shuffle(query)
    
    for item in query:
        out_file.write(item + '\n')   

For example, if the total randomization file was

random_total = ['9', '2', '3', '1', '5', '6', '8', '7', '0', '4']

and I would want a random set of 3, the result could be

random = ['9', '2', '3']

How can I select 50 from the list that I randomized?

Even better, how could I select 50 at random from the original list?

Edit
Report