# Python | sympy.factor_list() method

With the help of sympy.factor_list() method, we can get a list of factors of a mathematical expression in SymPy in the form of (factor, power) tuple.

Syntax: factor_list(expression)

Parameters:
expression – It is a mathematical expression.

Returns: Returns a list of factors of the given mathematical expression in the form of (factor, power) tuple.

Example #1:
In this example we can see that by using sympy.factor_list() method, we can get a list of factors of a given mathematical expression.

 `# import sympy ` `from` `sympy ``import` `*` `x ``=` `symbols(``'x'``) ` `expr ``=` `x``*``*``2` `*` `z ``+` `4` `*` `x``*``y ``*` `z ``+` `4` `*` `y``*``*``2` `*` `z ` ` `  `print``(``"Mathematical expression : {}"``.``format``(expr)) ` `   `  `# Use sympy.factor_list() method ` `f ``=` `factor_list(expr)  ` `   `  `print``(``"List of factors : {}"``.``format``(f))  `

Output:

```Mathematical expression : x**2*z + 4*x*y*z + 4*y**2*z
List of factors : (1, [(z, 1), (x + 2*y, 2)])
```

Example #2:

 `# import sympy ` `from` `sympy ``import` `*` `x ``=` `symbols(``'x'``) ` `expr ``=` `(x``*``*``2` `-` `2` `*` `x ``+` `1``) ` ` `  `print``(``"Mathematical expression : {}"``.``format``(expr)) ` `   `  `# Use sympy.factor_list() method ` `f ``=` `factor_list(expr)  ` `   `  `print``(``"List of factors : {}"``.``format``(f))  `

Output:

```Mathematical expression : x**2 - 2*x + 1
List of factors : (1, [(x - 1, 2)])
```

My Personal Notes arrow_drop_up Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

Article Tags :

Be the First to upvote.

Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.