python print combinations of string
test_str = "abc"
res = [test_str[i: j] for i in range(len(test_str))
for j in range(i + 1, len(test_str) + 1)]
print(res)#['a', 'ab', 'abc', 'b', 'bc', 'c']
python print combinations of string
test_str = "abc"
res = [test_str[i: j] for i in range(len(test_str))
for j in range(i + 1, len(test_str) + 1)]
print(res)#['a', 'ab', 'abc', 'b', 'bc', 'c']
python print combinations of string
import itertools
if __name__ == '__main__':
nums = list("ABC")
permutations = list(itertools.permutations(nums))
# Output: ['ABC', 'ACB', 'BAC', 'BCA', 'CAB', 'CBA']
print([''.join(permutation) for permutation in permutations])
python permutation
import itertools
a = [1, 2, 3]
n = 3
perm_iterator = itertools.permutations(a, n)
for item in perm_iterator:
print(item)
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us