Write a Python program to get all possible combinations of the elements of a given list
- برمجة
- برمجة بايثون
- 2021-04-16
- salsabeelalhams99111801528
الأجوبة
def combinations_list(colors):
if len(colors) == 0:
return [[]]
result = []
for el in combinations_list(colors[1:]):
result += [el, el+[colors[0]]]
return result
colors = ['orange', 'red', 'green', 'blue']
print("Original list:")
print(colors)
print("\nAll possible combinations of the said list’s elements:")
print(combinations_list(colors))أسئلة مشابهة
القوائم الدراسية التي ينتمي لها السؤال