r/pythonhelp • u/user101dt • Oct 18 '20
hw challenge question(pls help)
Create a text document called names.txt that contains a list of 20 names, each on its own line. Write a program that reads the names from names.txt and then generates a file called shuffle.txt that contains the names listed in random order. (Do not use the .shuffle() build in list method)
4
Upvotes
1
u/[deleted] Oct 19 '20 edited Oct 19 '20
Alright so you should start by breaking the problem down. First you need to open the file and extract the list of names, shuffle it, make a new file and write the list to it.
You could use
open()and.close()to opennames.txtand makeshuffle.txtbut for the sake of simplicity let's handle it withwith open() as varGoes like this: