https://www.acmicpc.net/problem/2577

 

2577번: 숫자의 개수

첫째 줄에 A, 둘째 줄에 B, 셋째 줄에 C가 주어진다. A, B, C는 모두 100보다 크거나 같고, 1,000보다 작은 자연수이다.

www.acmicpc.net

 

언어: 파이썬

난이도: 브론즈 4

코드

a = int(input())
b = int(input())
c = int(input())

num_list = list(str(a * b * c))

for i in range(10):
    print(num_list.count(str(i)))

 

 

런타임 에러 발생

- 입력값을 아래처럼 list로 받았더니 런타임 에러 발생

list1 = list(map(int, input().split()))
a = list1[0]
b = list1[1]
c = list1[2]

 

list 선언하는 방법이 여러가지라 잘 활용할 수 있도록 연습이 필요

# 변경 전 - list를 선언하고 append를 이용해 붙였는데
multiple = str(a * b * c)

num_list = []
for i in range(len(multiple)):
    num_list.append(multiple[i])



# 변경 후 - list()를 사용해 선언과 동시에 값 입력
num_list = list(str(a * b * c))

+ Recent posts