반응형
Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 | 29 |
30 | 31 |
Tags
- Kotlin
- 파이썬
- PANDAS
- matplotlib
- Python
- Redshift
- dataframe
- Java
- PostgreSQL
- django
- gas
- hive
- Apache
- GIT
- list
- Mac
- Github
- Tkinter
- PySpark
- Excel
- Google Spreadsheet
- Google Excel
- string
- google apps script
- math
- array
- c#
- SQL
- numpy
Archives
- Today
- Total
목록list 속 원소 개수 세기 (1)
달나라 노트
Python Basic : count (list 속의 특정 요소 개수 세기)
list.count(x) list에 count method를 적용시키면 count의 parameter로 전달된 값이 list 속에서 몇개가 존재하는지 세어줍니다. list_test = [1, 1, 2, 2, 2, 3, 3, 10, 5, 5, 5, 5, 8, 8, 7, 7, 'a', 'a', 'bb', 'bb', 'bb', '\n'] cnt_5 = list_test.count(5) # 1 cnt_a = list_test.count('a') # 2 cnt_line_break = list_test.count('\n') # 3 cnt_bb = list_test.count('bb') # 4 cnt_c = list_test.count('c') # 5 print(cnt_5) print(cnt_a) print(cnt_..
Python/Python Basic
2021. 6. 2. 00:32