python split word into letter pairs

Solutions on MaxInterview for python split word into letter pairs by the best coders in the world

showing results for - "python split word into letter pairs"
Jagger
11 Aug 2018
1string = 'ABCDXY'
2[string[i:i+2] for i in xrange(0, len(string), 2)]
Salomé
17 Apr 2016
1s = 'abcdef'
2L = zip(s[::2], s[1::2])
3# -> [('a', 'b'), ('c', 'd'), ('e', 'f')]