Python Assignment Solution on Trigrams