mirror of
https://github.com/TheAlgorithms/Python.git
synced 2025-02-25 18:38:39 +00:00
context manager for file handling changed too in from_file function
This commit is contained in:
parent
466d9925b2
commit
f176dd0027
@ -171,7 +171,8 @@ def solved(values):
|
||||
|
||||
def from_file(filename, sep="\n"):
|
||||
"Parse a file into a list of strings, separated by sep."
|
||||
return open(filename).read().strip().split(sep)
|
||||
with open(filename) as file:
|
||||
return file.read().strip().split(sep)
|
||||
|
||||
|
||||
def random_puzzle(assignments=17):
|
||||
|
Loading…
x
Reference in New Issue
Block a user