찾는 대상인 str1을 set으로 바꾼다.
set 형식은 중복 원소를 자동으로 제거해준다.
for tc in range(1,int(input())+1):
str1=set(list(input()))
str2=list(input())
maxx=0
for i in str1:
chk= str2.count(i)
if maxx<chk:
maxx=chk
print(f'#{tc} {maxx}'
문제에 적시된대로 딕셔너리 형식을 사용하면
for tc in range(1,int(input())+1):
str1=(list(input()))
str2=list(input())
chk=dict()
for i in str2:
if i in str1:
if i not in chk:
chk[i]=1
else:
chk[i]+=1
print(f'#{tc} {max(chk.values())}')
chk라는 딕셔너리를 새롭게 생성하여 str1의 수를 하나씩 더해줬다.