Question: I have 2 matrices in Python: Matrix A of shape (4,1) and Matrix B of shape(4,4).
I formed the 2 matrices using the data in a list.

valList data looks like

```
00200030
00200030
00200030
00200030
00480051
FFF0004B
FFF0004B

```

I converted each item into a 32 bit integer and then used the data to form the matrices.

```
for item in valList:
    int(item,32)

B_RC = createMatrix(rows,1,valList)
B = np.array(B_RC)
print B

A_RC = valList[rows:rows + (rows * cols)]
A = np.array(A_RC).reshape( (rows,cols))
print A

def createMatrix(rowCount, colCount, dataList):   
    mat = []
    for i in range (rowCount):
        rowList = []
        for j in range (colCount):
            if dataList[j] not in mat:
                rowList.append(dataList[i])
        mat.append(rowList)

    return mat

```

I want to multiply both the matrices.
I used numpy, but I get the following error for the code below:

```
>>> C=np.matmul(B,A)

error: ufunc 'matmul' did not contain a loop with signature matching types dtype('S8') dtype('S8') dtype('S8')

```

What function should i use?

Answer: 
you can do like this

`x = [ 'orange' if p>=80 else 'red' if 80>p >=60 else 'yellow' for p in list(extacted_data)]`
Readability and reusability ?
=============================

Chances are your business logic will need to be used in more than one place. Why not create a function that determines the color, then use list comprehension to create your list?

```
def colors(x):
    retval = 'yellow'
    if (x >= 80):
        retval = 'orange'
    elif(80 > x >= 60):
        retval = 'red'
    return retval

print([colors(x) for x in extracted_data])

```

Output
======

```
['orange', 'orange', 'red', 'yellow']

```