Python: Dictionary: Bigram Count

Write the function bigram_count that takes the file path to a text file (.txt) and returns a dictionary where key and value are the bigrams and their corresponding count. Assume the words in the string are separated by white-space and they are case-insensitive.


filepath = 'theodore-roosevelt.txt'
bigram_count(filepath) -> {'it is': 2,  'is hard': 1, 'hard to': 1, 'to fail': 1, 'fail but': 1, 'but it': 1, 'is worse': 1,
'worse never': 1,'never to': 1, 'to have': 1,'have tried': 1,'tried to': 1,'to succeed.': 1}

Test 1    

Test 2    

Test 3    

Test 4