(프로그래머스 with python) 튜플
Level2 - 튜플
https://programmers.co.kr/learn/courses/30/lessons/64065
문자열을 파싱하는 또다른 방법 : 파싱방법2 : s1 = s.lstrip('{').rstrip('}').split('},{')
def solution(s):
cand = []
dic = {}
s = list(map(int,s.replace('{','').replace('}','').split(',')))
for i in s:
if i not in dic:
dic[i] = 1
else:
dic[i] += 1
ans = sorted(dic.items(), key=lambda x: x[1], reverse=True)
res = [i[0] for i in ans]
return res
헤맸던 가장 큰 이유가 {}안에 ,의 기호로 문자열이 또 나뉘어져 있는걸 모르고 {}을 무조건 하나의 숫자라고 생각하고 풀이했다.. 제대로 읽고 문제 풀자 !!!