Apr-30-2017, 05:11 PM
Itertools is cool to get every combination, or you can also just iterate over the list.
word = "abcde" twoletter = [] for left in word: for right in word: if left != right: twoletter.append(left + right) print(twoletter) # ['ab', 'ac', 'ad', 'ae', 'ba', 'bc', 'bd', 'be', 'ca', 'cb', 'cd', 'ce', 'da', 'db', 'dc', 'de', 'ea', 'eb', 'ec', 'ed']