write a python function that takes the name of a text file as input along with a python list, and writes the contents of the list to the text file
Here is a Python function that does what you described:
```
def write_list_to_file(filename, my_list):
    with open(filename, 'w') as f:
        for item in my_list:
            f.write(str(item) + '\n')
```
Here's an explanation of how the function works:

* The `with` statement opens the file specified by `filename` in write mode (`'w'`). The file is automatically closed when we're done with it, regardless of whether an exception is thrown or not.
* The `for` loop iterates over the elements of `my_list`.
* For each element, we convert it to a string using the `str()` function, and then write it to the file using the `write()` method. We add a newline character (`'\n'`) to the end of each line so that each element is written on a separate line.

You can use this function like this:
```
my_list = [1, 2, 3, 4, 5]
write_list_to_file('example.txt', my_list)
```
This would create a file called `example.txt` with the contents:
```
1
2
3
4
5
```
Note that if the file already exists, its contents will be overwritten. If you want to append to the file instead of overwriting it, you can change the `open` mode from `'w'` to `'a'`. For example:

def write_list_to_file(file_name, list_data):
    with open(file_name, 'w') as f:
        for item in list_data:
            f.write(str(item) + '\n')

write_list_to_file('list_file.txt', [1, 2, 3, 4, 5])