[파이썬] 배열 - count(),set(),정수를배열로

에구마·2022년 2월 2일
0

Python

목록 보기
3/11

count()

배열에서 해당값이 몇번이나 존재하는지 반환

apple.count('p') 
>> 2

🔥#2577번 문제

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

result = list(str(a * b * c))
for i in range(10):
    print(result.count(str(i)))

set()

집합 자료형
set(배열) -> 집합 자료형으로 변환 중복이 제거됨!
list(집합) -> list형으로 변환 : len등을 적용할 수 있음

🔥#3052번 문제

arr = []
for i in range(10):
  n = int(input())
  arr.append(n%42)

my_set = set(arr)
my_list = list(my_set)
print(len(my_list))

=

정수를 배열로

num = 12345
strnum = list(map(int,str(num)))
 >> [1,2,3,4,5]
profile
Life begins at the end of your comfort zone

0개의 댓글