import tempfile with tempfile.NamedTemporaryFile(mode='w', delete=False) as temp_file: lines = ['Hello', 'world', 'from', 'tempfile'] temp_file.writelines(line + '\n' for line in lines) print(f'Temporary file created at {temp_file.name}')In this example, we first create a temporary file using the `NamedTemporaryFile` function with the `mode` parameter set to `'w'` to indicate that we want to write to the file. We also set the `delete` parameter to `False` so that the file is not deleted when we close it. Next, we define a list of strings that we want to write to the file. We use a list comprehension and the `writelines()` method to write each element of the list to the file followed by a newline character. Finally, we print the name of the temporary file that was created. This example uses the `tempfile` package that is part of the Python standard library.