You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The `itertools` is a built-in module in Python 3 and is helpful for us to use a more pythonic way to manipulate the iterables (e.g., list, set, tuple, etc.).
4
+
5
+
Another advantage of `itertools` is it also returns the [generator](../must_know/generator.md) type instances that have benefits of **lazy evaluation** from all of its methods.
6
+
7
+
In this section, we will discuss the third part of `itertools`. The methods in this section are all about the combinatoric methods in discrete mathematics.
|`iterable`, `r`| combination with length `r`|`combinations("ABC", 2)= AB, AC, BC`|
75
+
76
+
```py
77
+
gen = combinations("ABC", 1)
78
+
list(gen)
79
+
# [A, B, C]
80
+
81
+
82
+
gen = combinations("ABC", 2)
83
+
list(gen)
84
+
# [AB, AC, BC]
85
+
86
+
87
+
gen = combinations("ABC", 3)
88
+
list(gen)
89
+
# [ABC]
90
+
```
91
+
92
+
## combinations_with_replacement
93
+
94
+
This table takes [Python documentation #combinations_with_replacement](https://docs.python.org/3/library/itertools.html#itertools.combinations_with_replacement) as reference.
Copy file name to clipboardExpand all lines: itertools/infinite_iterators.md
+8-8Lines changed: 8 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,7 @@
2
2
3
3
The `itertools` is a built-in module in Python 3 and is helpful for us to use a more pythonic way to manipulate the iterables (e.g., list, set, tuple, etc.).
4
4
5
-
Another advantage of `itertools` is it also returns the [generator](../must_know/generator.md) type instances that have benefits of **lazy evaluation** from all its methods.
5
+
Another advantage of `itertools` is it also returns the [generator](../must_know/generator.md) type instances that have benefits of **lazy evaluation** from all of its methods.
6
6
7
7
In this section, we will discuss the first part of `itertools`. The methods in this part all return a generator that generates an infinite number of items and won't stop.
8
8
@@ -19,9 +19,9 @@ In this section, we will discuss the first part of `itertools`. The methods in t
19
19
20
20
This table takes [Python documentation #count](https://docs.python.org/3/library/itertools.html#itertools.count) as reference..
Copy file name to clipboardExpand all lines: itertools/terminated_iterators.md
+13-13Lines changed: 13 additions & 13 deletions
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,7 @@
2
2
3
3
The `itertools` is a built-in module in Python 3 and is helpful for us to use a more pythonic way to manipulate the iterables (e.g., list, set, tuple, etc.).
4
4
5
-
Another advantage of `itertools` is it also returns the [generator](../must_know/generator.md) type instances that have benefits of **lazy evaluation** from all its methods.
5
+
Another advantage of `itertools` is it also returns the [generator](../must_know/generator.md) type instances that have benefits of **lazy evaluation** from all of its methods.
6
6
7
7
In this section, we will discuss the second part of `itertools`. The methods in this part all return a generator that generates finite items corresponding to your input.
8
8
@@ -28,9 +28,9 @@ In this section, we will discuss the second part of `itertools`. The methods in
28
28
29
29
This table takes [Python documentation #accumulate](https://docs.python.org/3/library/itertools.html#itertools.accumulate) as reference.
0 commit comments