[Python] [백준 #11720] 숫자의 합

박수경·2021년 11월 1일
0
post-thumbnail

문제

11720


풀면서 하는 생각

입력받은 수들을 str로 리스트에 넣은 후 int로 바꿔서 for문을 숫자의 개수만큼 돌려서 더하면 되지 않을까?

제출한 코드

cnt = int(input())
num = list(input())
num_list = list(map(int, num))

sum = 0

for i in range(0, cnt):
    sum = sum + num_list[i]

print(sum)

결과

profile
유니콘을 위하여

0개의 댓글

Powered by GraphCDN, the GraphQL CDN