All problems
Trigram Total Count
Problem
The number of trigrams in a token list is max(0, len(tokens) - 2).
Given the token list, return the trigram count.
Hint
Each trigram consumes a window of three consecutive tokens.
Test cases
case 1
in: [["a","b","c","d"]]
expected: 2
case 2
in: [["a","b"]]
expected: 0
case 3
in: [[]]
expected: 0
Starter codePython
def trigram_total_count(tokens):
# Your code here
pass3 test cases · run your code against them in the editor