Both the combinations and permutations have almost the same explanation.
“Elements are treated as unique based on their position, not on their value, so if the input elements are unique, there will be no repeated values within a permutation.”
English is not my native language. Did I misunderstand it?
The two functions serve different purposes. I showed above a couple of examples of permutations; they’re taking ALL of the different elements, and showing you the ways they can be arranged. The permutations of "abc" are all the different ways you can shuffle those three letters around. You might put the a first, in which case you can either put b and then c or c and then b; or you might put b first; or you might put c first. Every option will have all three letters, but in a different order. A permutation is an arrangement of the original things.
Combinations, however, are all about choosing some of those things. If I were to pick two letters from "abcde", what are the possible pairs I could pick?
With combinations, we don’t care which one got selected first, just that these got selected. And the note that you’re citing is important here, because identical elements will still be available to be selected, even though that might be confusing. For example:
I think my misunderstanding is caused by that I thought the “Elements” mentioned in sentence “Elements are treated as unique based on their position, not on their value” are those of the result, and “they are of the input” never comes to my mind:-(
Also, I had referenced the page “https://www.britannica.com/science/permutation” where one of the sentences in their explanation aroused my further suspicion about the docs.
Quote: “permutations and combinations, the various ways in which objects from a set may be selected, generally without replacement, to form subsets. This selection of subsets is called a permutation when the order of selection is a factor, a combination when order is not a factor.”
Yep! That’s exactly true, but I actually ignored part of that for simplicity’s sake. You can pass a second argument to itertools.permutations to choose how long you want the results to be, and then it’ll be the same as combinations but with each distinct ordering being included.