You can use re module of python for matching a specific pattern. re stands for regular expressions. For example
[A-Z] will match exactly one character between A and Z
\d+ will match one or more digits
() group things (and also return things... but for now just think of them grouping)
+ selects 1 or more
You can refer to the following code to understand it better
import re
pattern = re.compile("^([A-Z][0-9]+)+$")
pattern.match(string)