I wrote my code in python 3. It works perfectly fine on the python ide and programiz online ide but gives RUNTIME error on the google platform. can someone help out as to why this is happening? Here's the link to the problem:Vestigium
def main(x,n,N):
n = len(x)
r = 0
for i in x:
if len(i)> len(set(i)):
r += 1
cols = []
k = 0
for i in range(n):
col = []
for j in range(n):
col.append(x[i][j])
if i == j:
k += int(x[i][j])
cols.append(col)
c = 0
for i in cols:
if len(i)> len(set(i)):
c += 1
print("Case #",N,":",k,r,c,)
N = int(input())
for i in range(N):
x = []
n = int(input())
for j in range(n):
row = []
for p in range(n):
v = int(input())
row.append(v)
x.append(row)
num = i + 1
main(x,n,num)
input()for each element of a row, which gives an error. You're supposed to handle the entire line as one input. ReplaceWith
This prints
Case # 1 : 1. The program clearly specifies the output to be inCase #1: 1format. The extra space between#and case number causes an error. Using Python 3 and above, use an f-string to make it easier.This should fix the Runtime Error. I still suspect it will give a wrong answer though.