Created
October 9, 2021 06:36
-
-
Save otamajakusi/593c2d9bde877229bb6ee97b53fbf8c7 to your computer and use it in GitHub Desktop.
python itertools
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
text = "ABCDE" | |
l = len(text) | |
for s, e in itertools.combinations(range(l+1), 2): | |
print(text[s:e]) | |
""" | |
A | |
AB | |
ABC | |
ABCD | |
ABCDE | |
B | |
BC | |
BCD | |
BCDE | |
C | |
CD | |
CDE | |
D | |
DE | |
E | |
""" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment