I want to count the occurrence of words which are followed by each other in a given list using python. E.g.
my_list = ['ABC', 'DEF', 'PQR', 'ASD', 'ABC', 'DEF', 'ZXC', 'ABC', 'PQR']
In the above list, the count of times when 'ABC'
is followed by 'DEF'
is 2
.
Kindly help me out. Thanks.