def tokenize(chars):
    """Convert a string of characters into a list of tokens."""
    # Idea from http://norvig.com/lispy.html
    line = chars.replace(
        '[', ' [ ').replace(']', ' ] ').replace(',', ' ').split()

    for i, v in enumerate(line):
        if v != '[' and v != ']':
            line[i] = int(v)
    return(line)