3 examples of 'python powerset' in Python

Every line of 'python powerset' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Python code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
31def powerset(s):
32 s = list(s)
33 combinations = (itertools.combinations(s, r) for r in range(len(s) + 1))
34 return itertools.chain.from_iterable(combinations)
49def genPowerSet(items):
50 result = [[]]
51 for x in items:
52 result.extend([subset + [x] for subset in result])
53 return result
52def perform_power():
53 print("POWER")
54 print("Input 1st operand:")
55 add_var_1 = int(input())
56 print("Input 2nd operand:")
57 add_var_2 = int(input())
58 print("Result:")
59 print(add_var_1 ** add_var_2)

Related snippets