我曾在Google Kick Start 2016 Round A(国家领导人)上练习,但我遇到错误,提示运行时错误,无法弄清楚什么地方出了问题。 这是我的代码 第一个:
T = int(input().strip())
tries = []
for i in range(1, T + 1):
N = int(input().strip())
persons = list()
for t in range(1, N + 1):
persons.append(input().strip())
tries.append(persons)
winners = []
for t in tries:
points = 0
temp = ''
for per in t:
per_ltr = per.replace(' ','')
if len(set(per_ltr)) > points:
points = len(set(per_ltr))
temp = per
winners.append(temp)
num = 1
for one in winners:
print(f'Case #{num}: {one}')
num += 1
另一个:
T = int(input())
winner = []
for i in range(T):
N = int(input())
persons = []
for j in range(N):
persons.append(input())
points = len(set(persons[0]))
temp = persons[0]
for per in persons:
if len(set(per)) > points:
points = len(set(per))
temp = per
winner.append(temp)
num = 1
for one in winner:
print(f'Case #{num}: {one}')
num += 1