+ 6
What is the error..It is showing in line 18..
5 Réponses
+ 3
As far as I understand, Your program does the calculations correctly, but you have problems with the display. To improve the quality of the display, I removed the text when entering and slightly corrected the printing in the loop. Total we have:
def diagonal(lst):
print("Both diagonals")
for i in range(len(lst)):
for j in range(len(lst[i])):
if i == j or (i + j) == len(lst) - 1:
print(' ' * j, lst[i][j], end='', sep='')
print()
def show(lst):
print("Given")
for i in range(len(lst)):
for j in range(len(lst[i])):
print(lst[i][j], end=' ')
print()
lst=eval(input())
show(lst)
print('-' * 25)
diagonal(lst)
In this Case, you need to submit a matrix of numbers to the Program. For example:[[1, 2, 3], [4, 5, 6], [7, 8, 9]].
+ 8
actually we have to print diagonal of
123
456
789 as
1 3
5
7 9 in this way
+ 6
Thanks a lot Rustam Yusupov Thanks for your help..😀😀😀😊😊😊😊
+ 1
I apologize for possible errors in the text, as I use a translator.
0
Could you give me those inputs where the error occurs?