python - Create new lists with del function -
i have list
a = ['a', 'b', 'c'] and want create function delete print new list lists['a', 'b'], ['b', 'c'] , ['a', 'c'].
my main goal here designing function return set of lists consisting of main list without element of it.
what want combinations of length n-1 n length of list.
>>> itertools import combinations >>> = ['a', 'b', 'c'] >>> map(list, combinations(a, len(a)-1)) [['a', 'b'], ['a', 'c'], ['b', 'c']] this give list of lists. note set of lists requested not possible because lists not hashable.
Comments
Post a Comment