celina의 이것저것
[프로그래머스] Lv.0 숨어있는 숫자의 덧셈(1) Python (isdigit) 본문
반응형
def solution(my_string):
num = '1234567890'
total = 0
for i in my_string:
if i in num:
total += int(i)
return total
isdigit()써서 한번에 해결 ㄷ ㄷ
=def solution(my_string):
return sum(int(i) for i in my_string if i.isdigit())
'자료구조&알고리즘 > 프로그래머스' 카테고리의 다른 글
[프로그래머스] Lv.0 문자열 정렬하기 (1) python (sorted) (0) | 2024.05.06 |
---|---|
[프로그래머스] Lv.0 팩토리얼 python (0) | 2024.05.05 |
[프로그래머스] Lv.0 배열 회전시키기 (dequeue함수) (0) | 2024.05.04 |
[프로그래머스] Lv.0 진료순서 정하기 (0) | 2024.05.03 |
List Comprehension (0) | 2024.04.29 |
Comments