Lv2 프로그래머스(Programmers)[Python][파이썬] 뉴스 클러스터링

"""
출처:프로그래머스,
https://school.programmers.co.kr/learn/courses/30/lessons/17677
"""
# 풀이 과정
def solution(str1, str2):
# a,b 모두 공집합일 경우 자카드 유사도 1로 정의

eng = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
eng = list(eng)

str1 = list(str1.upper())
str2 = list(str2.upper())

a = [] # str1 집합
b = [] # str2 집합

u = 0
n = 0

for i in range(len(str1) - 1):
new = ""
if str1[i] in eng:
new += str1[i]
else:
continue

if str1[i + 1] in eng:
new += str1[i + 1]
else:
continue

a.append(new)

for i in range(len(str2) - 1):
new = ""
if str2[i] in eng:
new += str2[i]
else:
continue

if str2[i + 1] in eng:
new += str2[i + 1]
else:
continue

if new in a:
u += 1
n += 1
k = a.index(new)
del a[k]
else:
u += 1

u += len(a)

if u == 0 and n == 0:
return 65536
else:
return int((n / u) * 65536)