How to find the probabilities of certain events occurring in a defined sequence? Good day, everyone!

I have a problem where I have to program something like this:

I have some arbitrary number of events, let's call then Event A, B, C, D, E, F, ... and so on.

Now they occur in well defined sequences, just like below:

[A, A, C, A, A, A, F, B, A]


That's just a random sample, I have a data of thousands of such event sequences, and there are going to be 9 events in every sequence.

What I'm trying to do is to calculate the probability of each individual event happening. Like:


what's the probability of event A occurring first
what's the probability of event B occurring, given that the previous event was A
what's the probability of event C occurring, given that the previous two events were A and B


So far I've gone through the maths behind conditional/joint probabilities, markov chains, but I can't get to come up with the programming part. Are there any leads to where I can get my hands on some framework, library, or a tool which will help me run the simulation with all of my sequences, and give any finalised probabilities?

Thanks!

P.S: For those who are aware of MLB, I'm just trying to find the probabilities of certain scores being made in all the 9 innings based on past scores. If I calculate the simple probability of a score being made, I get a very high probability of zero, which is not the case. I only have the data for the box scores.
My answer is inspired by this question in Code Review SE

import random
import string
from collections import Counter

def test_data(n, m, choices):
    return [[random.choice(choices) for _ in range(m)] for _ in range(n)]

data = test_data(50000, 9, ["A", "B", "C", "D", "E", "F"])

def subsequence_counts(sequences):
    return Counter([seq for seq in map(''.join, sequences)])

counter = subsequence_counts(data)

print(counter['BCEEECFAF'])


What the above code does:

1) The test_data function, creates a n lists with m items using elements of the choices parameters.

In specific, we create 50000 lists with 9 items length using the capital letters A, B, C, D, E, F

This is just for testing the code

2) The function subsequence_counts uses a list comprehension and a Counter to keep track of every single combination of the sublists we have. 

3) Finally, you can access the Counter and get the frequency of any event you want.