develop/Python
[프로그래머스/파이썬] 문자열 정렬하기(1)
hsleeee
2023. 2. 24. 17:05
반응형
SMALL
def solution(my_string):
answer = list()
for i in my_string:
if (i.isdecimal()):
answer.append(int(i))
return sorted(answer)
string.isdecimal() 함수를 사용하여 숫자인지 판별
answer 리스트에 자료형을 int로 바꿔서 append
sorted 함수를 사용하여 answer 정렬하여 리턴
반응형
LIST