mirror of
https://github.com/TheAlgorithms/Python.git
synced 2025-07-24 16:55:45 +08:00
Fix ResourceWarning: unclosed file (#681)
Signed-off-by: Mickaël Schoentgen <contact@tiger-222.fr>
This commit is contained in:

committed by
Libin Yang

parent
3dc50529ca
commit
2d70e9f747
@ -4,7 +4,8 @@ import collections, pprint, time, os
|
||||
start_time = time.time()
|
||||
print('creating word list...')
|
||||
path = os.path.split(os.path.realpath(__file__))
|
||||
word_list = sorted(list(set([word.strip().lower() for word in open(path[0] + '/words')])))
|
||||
with open(path[0] + '/words') as f:
|
||||
word_list = sorted(list(set([word.strip().lower() for word in f])))
|
||||
|
||||
def signature(word):
|
||||
return ''.join(sorted(word))
|
||||
|
Reference in New Issue
Block a user