with open(path, "w", encoding="utf-8") as outfile:
[outfile.write(d + "\n") for d in data]
I don't understand the use of the square brackets in this statement. From my understanding, this will create a new list, and when I delete the square brackets, I get the error:
File "test.py", line 6
outfile.write(d + "\n") for d in data
^
SyntaxError: invalid syntax
How to understand the "[]" in this code. Thanks in advance.