Buzzerb
Mar 11, 2017 - 12:42
I am attempting to write a program, within which I need to load a file, and remove all punctuation from it. In attempting to do so, I receive a 'set' object does not support indexing error. I am not sure which variable is a set, and why this is failing. A simplified version of my code is below
import string
input_file = open("Test1.txt", "r") #Open the file 'Test1'
input_file = input_file.read() #Convert the file to a string
input_file = input_file.translate({None for a in string.punctuation}) #Attempt to remove punctuation.
#The error is thrown by the above line