@ Alasdair прав ... используйте itertools.
Код:
from itertools import permutations
places = ['charity','hospital','carrefour']
result = list(permutations(places, 2)
Выход:
[('charity', 'hospital'), ('charity', 'carrefour'), ('hospital', 'charity'), ('hospital', 'carrefour'), ('carrefour', 'charity'), ('carrefour', 'hospital')]
Код:
from itertools import permutations
places = ['charity','hospital','carrefour']
result = [list(place) for place in list(permutations(places, 2))]
Выход:
[['charity','hospital'],['charity','carrefour'],['hospital','charity'],['hospital','carrefour'],['carrefour','charity'],['carrefour','hospital']]