How to target variable names in uppercase without including the data type

80 Views Asked by At

I am trying to write a test in Python that flags variable name chars that are upper case. However some of the data types I am targeting are also written in upper case. How would I split the text in such a way that it’s targeting the name only, after the data type but before the ‘=‘ operator. Alternatively is there a way to exclude any upper case in the data type and start counting from the index position after a match from the list.

Example of a variable I am trying to target. I want to ignore any capital letters in the data type eg.(Bool) but flag upper case in the variable name only eg.(‘N’). I don’t want to catch any capitals after the ‘=‘

    # example variable in line text

    line_text: Bool Number one = dogs

    list = [int, Int, Bool, bool]

    issues = []

    for item in list:
        if item in line_text.split(‘=‘)[0]
            for char in line_text.split(‘=‘)[0]
                if char is.upper():       
                    issues.append({ line_number})
0

There are 0 best solutions below