list1=[([item],[item2]) for item in prefs for item2 in prefs if item!=item2 ]
а я хочу получить только уникальные.
if item!=item2 это всё что я смог придумать((((
list1=[([item],[item2]) for item in prefs for item2 in prefs if item!=item2 ]
>>> l1 = [1, 2, 3, 4, 5]
>>> [(a, b) for a in l1 for b in l1 if a<b]
[(1, 2), (1, 3), (1, 4), (1, 5), (2, 3), (2, 4), (2, 5), (3, 4), (3, 5), (4, 5)]
>>> l=['ff',45,'ey']
>>> [(a, b) for a in l for b in l if a<b]
[(45, 'ff'), (45, 'ey'), ('ey', 'ff')]
>>> l=['ff',45, 'ey']
>>> [(a,b) for a in l for b in l if a<b]
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<stdin>", line 1, in <listcomp>
TypeError: unorderable types: str() < int()
>>>
beliy_shumpy3k?
!!!!!!!!!!!!!!!!!!!!!!!!!>>> l=['ff',45, 'ey']
>>> [(a,b) for a in l for b in l if a<b]
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<stdin>", line 1, in <listcomp>
TypeError: unorderable types: str() < int()
>>>