n, m = input('n * m ').split()
n, m = int(n), int(m)
M = []
for i in range(n):
tmp = list(int(el) for el in input().split())
if len(tmp) != m:
raise ValueError
M.append(tmp)
for i in range(n):
for j in range(m):
if i == j or i == m-j-1:
continue
else:
M[i][j] = 0
for row in M:
print(row, sep=' ')
output should not be like this:
[4, 0, 0, 0, 4]
[0, 4, 0, 7, 0]
[0, 0, 8, 0, 0]
[0, 6, 0, 2, 0]
[3, 0, 0, 0, 3]
output should be like this without square brackets and coma:
4 0 0 0 4
0 4 0 7 0
0 0 8 0 0
0 6 0 2 0
3 0 0 0 3
L = []
for _ in range(0, int(raw_input())):
user_input = raw_input().split(' ')
command = user_input.pop(0)
if len(user_input) > 0:
if 'insert' == command:
eval("L.{0}({1}, {2})".format(command, user_input[0], user_input[1]))
else:
eval("L.{0}({1})".format(command, user_input[0]))
elif command == 'print':
print L
else:
eval("L.{0}()".format(command))
Comments
Leave a comment