Archived
shifted zip
An old note — I haven't updated it since I wrote it.
It's sometimes useful to compare words in a list.
Given the words:
1aaa
2bbb
3ccc
Compare them as so:
1aaa < bbb
2bbb < ccc
3ccc < ddd
Solution:
1words = 'aaa bbb ccc ddd'.split()
2
3for first, second in zip(words, words[1:]):
4 print(first, '<', second)