I am writing a function that contains a list of numbers, and I need to find a way to count the occurrences of the numbers 1 and 2, only for the last 3 values of the list.
I obviously know of the .count() function, but I'm wondering if there's a way to use that only between a given index, in this case that index would be ((len(history-3), (len(history)), history being a list containing only values 1 and 2.
TL;DR: What is a way to count occurrences of values in a list between given indexes.
 
     
     
    