UnicodeDecodeError
Cell In[34], line 8
6 # reading the file
7 with open('Hamlet.txt') as f:
Traceback (most recent call last)
----> 8 lines = [line.rstrip() for line in f]
10 # removing punctuation
11 s = [sent.translate(str.maketrans('', '', string.punctuation)).split() for sent in lines if sent != '' ]
Cell In[34], line 8, in <listcomp>(.0)
6 # reading the file
7 with open('Hamlet.txt') as f:
----> 8 lines = [line.rstrip() for line in f]
10 # removing punctuation
11 s = [sent.translate(str.maketrans('', '', string.punctuation)).split() for sent in lines if sent != '']
File ~\anaconda3\Lib\encodings\cp1252.py:23, in IncrementalDecoder.decode(self, input, final)
22 def decode(self, input, final=False):
---> 23 return codecs.charmap_decode(input, self.errors, decoding_table)[0]
UnicodeDecodeError: 'charmap' codec can't decode byte 0x9d in position 2331: character maps to <undefined>