Python Forum

Full Version: Does stack overflow exist in python ?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi all. I am working on a file using many matrixes. So I have problems with the interpreter. It seems broken. Is that "stack overflow". If it is "stack overflow", what shall I do to make it disappear ?

my code here
I don't know if it's a stack overflow. You need to post exactly what the interpreter is telling you (or doing), or I can't explain what it is telling you (or doing).
There is no long time I started my PC. I tried another file with less matrixes and fortunately it works well. It is strange that Mark Lutz does not refer to "stack overflow". Tell me please if it really exists in an interpreter, as it exists in a compiler of C++. Thanks
I kept all the matrixes. I only changed positions of matrixes in the file. Now every thing works well. Here is the new code:...
#file9.py
from pprint import pprint

print("MULTIPLICATION TABLE")
def pause():
   input("Press ENTER to continue")


M = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
    [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
    [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
    [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
    [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
    [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
    [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
    [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
    [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
    [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]
print("New values in the matrix")
for i in range(len(M)):
   for j in range(len(M)):
       M[i][j] = i * j

pprint(M)
pause()
print("This multiplication_table 'N' is a matrix beginning by a 1")
N = []
for x in range(1, 10):
   new_row = []
   for y in range(1, 10):
       new_row.append(x * y)
   N.append(new_row)
pprint(N)


pause()
print("\nNow a display of the same, row by row")
for row in N[0:]:  # begin by item 0
   print(row[0:])  # begin by item 0

pause()
print("The following 'P' is a matrix")
P = [[x * y for y in range(1, 10)] for x in range(1, 10)]
pprint(P)

pause()
print("\nNow action between the 2 matrixes 'M', beginning with a 0, and 'N' with a 1 ")
print([M[row][col] * N[row][col] for row in range(5) for col in range(5)])
print("second action")
print([[M[row][col] * N[row][col] for row in range(5)] for col in range(5)])


pause()
print("New 'P'  in a square")
for i in range(len(P)):
   for j in range(len(P)):
       if len(str(P[i][j])) == 1:
           P[i][j] = " " + str(P[i][j])
       else:
           P[i][j] = str(P[i][j])
for x in range(len(P)):
   print(P[x])

exit()