I have a list of filenames in python and I would want to construct a set out of all the filenames.
list
set
filelist=[] for filename in file
The most direct solution is this:
s = set(filelist)
The issue in your original code is that the values weren't being assigned to the set. Here's the fixed-up version of your code:
s = set() for filename in filelist: s.add(filename) print(s)