1
이 숙제 문제에 문제가 있습니다. 문자열에서 연속되는 "특수 기호"의 최대 수를 반환하십시오.
def symbol_count(s:str): -> int
"""Return the largest number of consecutive "special symbols" in the
string s.
>>> symbol_count(’c0mput3r’)
0
>>> symbol_count(’H! [here’)
1
>>> symbol_count(’h3!!&o [email protected]#’)
3
"""
lst = []
count = 0
for i in range(len(s)-1):
if s[i] in SPECIAL_SYMBOLS:
count +=1
if s[i+1] not in SPECIAL_SYMBOLS:
lst.append(count)
count = 0
else:
count += 1
if lst == []:
return 0
return max(lst)
SPECIAL_SYMBOLS = '[email protected]#$%^&*()_+=[]?/'
정말 고마워요! 정말로 나를 거기에서 구했다. – DWCY