Reading files into Python

f = open("1.txt")
#create a text file which consists of names of students in class
# Printing file all the names
print("File contnet as in text file:",f.read())
f = open("1.txt")
# Printing file one by one letters
print("\nFile contnet one by one word fromtext file:")
next = f.read(1)
while next != "":
    print(next)
    next = f.read(1)

Multiplication of two Matrices

X = [[4,1,7],[2,1,8],[3 ,7,1]];
Y = [[6,8,1],[9,7,5],[2,3,1]];
result = [[0,0,0],[0,0,0],[0,0,0]];
        
for i in range(len(X)):
     for j in range(len(Y[0])):
         for k in range(len(Y)):
             result[i][j] += X[i][k] * Y[k][j]

for r in result:
 print(r)