I'm learning Python, and as a small exercise I made for myself I'm writing a program to find the determinate of a 2x2 matrix. I'm running Python 2.5 on Windows Vista, here's my code.
The error I get tells me that the elements of matrix are strings and thus the * operation cannot be performed on them.
I'm a bit embarrassed to ask such a simple question, but I really know very little about Python and I've done as much research as I can given the resources I have (how I found int() which doesn't seem to work). Advice?
Code:
#for loop test.
#Finding the determinate of a 2x2 matrix
matrix = []
newelement = raw_input("Enter your first value: ")
matrix.append(newelement)
while len(matrix) < 4:
nextelement = raw_input("enter your next element: ")
matrix.append(nextelement)
int(matrix[0])
int(matrix[1])
int(matrix[2])
int(matrix[3])
determinate = (matrix[0]*matrix[3])-(matrix[1]*matrix[2])
print "The determinate of your matrix is "+ determinate +"."
I'm a bit embarrassed to ask such a simple question, but I really know very little about Python and I've done as much research as I can given the resources I have (how I found int() which doesn't seem to work). Advice?
Comment