Please help.
Why I'm I getting a syntax error.

In python, the word list is a keyword. It's not meant to be used for a variable. Try changing list to lst. There also might be other parts wrong with your code. If we could take a look at your whole function, we could determine if there is anything else wrong with your code.