I'm trying to create a program that will prompt the user for a list of text 
files to read from, then read those text files and build a dictionary of all 
the unique words found. Then finally put those unique words into another file 
and make it alphabetical order.

What I've got:

import string

s = input("Enter a file name: ") + ".txt"
filepath = "I:\\" + s

# remove all punctuation marks and make lower case
s_nopunct = "".join(c for c in s if c not in string.punctuation).lower()

# convert to a sorted list of unique words via set comprehension
list_unique = sorted(list({word for word in s_nopunct.split()}))

print("\nSorted list of unique words in sentence:")
print(list_unique)

with open("C:\\Users\\Desktop\\words.dat", "w") as f:
    for x in list_unique:
        f.write(x + "\n")

I need help making it so that the user is prompted to enter at least 3 files.
And also, I tried making those unique words to write to another file (I got it 
that far), but how do I make it more of an arbitrary path (rather than the 
C:\Users etc) since I need it so that anyone can run that program and 
write/find to that file.
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to