Because sometimes new questions are marked as duplicates and their authors are referred to this question it may be important to mention that **sympy** has an iterator for this purpose.

```
>>> from sympy.utilities.iterables import multiset_permutations
>>> list(multiset_permutations([1,1,1]))
[[1, 1, 1]]
>>> list(multiset_permutations([1,1,2]))
[[1, 1, 2], [1, 2, 1], [2, 1, 1]]
```

### Related Contents:

- How to generate all permutations of a list?
- How do I use itertools.groupby()?
- Permutations between two lists of unequal length
- Finding all possible permutations of a given string in python
- Generating permutations with repetitions
- Shuffle DataFrame rows
- Generate a random derangement of a list
- Generate permutations of list with repeated elements
- itertools product speed up
- How do I generate all permutations of a list?
- Python how to read N number of lines at a time
- How to apply itertools.product to elements of a list of lists? [duplicate]
- itertools.groupby() not grouping correctly
- importing izip from itertools module gives NameError in Python 3.x
- N-D version of itertools.combinations in numpy
- Python recursion permutations
- All possible permutations of a set of lists in Python
- Finding the index of an item in a list
- How can I include a folder with cx_freeze?
- Understanding dict.copy() – shallow or deep?
- append multiple values for one key in a dictionary [duplicate]
- Why can’t non-default arguments follow default arguments?
- Convert UTF-8 with BOM to UTF-8 with no BOM in Python
- Pythonic way of checking if a condition holds for any element of a list
- How do you convert a time.struct_time object into a datetime object?
- Django Rest Framework File Upload
- Compiling with cython and mingw produces gcc: error: unrecognized command line option ‘-mno-cygwin’
- Is there a “not equal” operator in Python?
- In Python, how do you convert seconds since epoch to a `datetime` object?
- numpy np.apply_along_axis function speed up?
- Checking File Permissions in Linux with Python
- Generate a list of datetimes between an interval
- Django: “projects” vs “apps”
- How to have clusters of stacked bars
- Interpolate NaN values in a numpy array
- What is the correct syntax for ‘else if’?
- How can I translate dates and times from natural language to datetime? [closed]
- Using a Python dict for a SQL INSERT statement
- Displaying a webcam feed using OpenCV and Python
- Insert row into Excel spreadsheet using openpyxl in Python
- Unable to get local issuer certificate when using requests in python
- General bars and stars
- floating point in python gives a wrong answer [duplicate]
- How to update/upgrade a package using pip?
- What is the Python 3 equivalent of “python -m SimpleHTTPServer”
- Subclassing dict: should dict.__init__() be called?
- Pandas: combining header rows of a multiIndex DataFrame
- Using subprocess.run with arguments containing quotes
- flake8 complains on boolean comparison “==” in filter clause
- dictionary update sequence element #0 has length 3; 2 is required