Answers for "python all possible combinations string"

5

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']
Posted by: Guest on May-26-2021
0

python combinations

import itertools
def subs(l):
    res = []
    for i in range(1, len(l) + 1):
        for combo in itertools.combinations(l, i):
            res.append(list(combo))
    return res
Posted by: Guest on September-02-2021
0

python possible combinations

import math
n=7
k=5
print(math.comb(n, k))
Posted by: Guest on October-01-2021

Code answers related to "python all possible combinations string"

Python Answers by Framework

Browse Popular Code Answers by Language