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
- string
- data
- append()
- Dictionary
- 덴드로그램
- 분류 결과표
- matplotlib
- IN
- pandas
- list
- analizer
- elbow method
- count()
- nan
- del
- wcss
- numpy
- 최댓값
- insert()
- sklearn
- dendrogram
- Python
- hierarchical_clustering
- DataAccess
- len()
- Machine Learning
- 반복문
- DataFrame
- function
- 최솟값
Archives
- Today
- Total
개발공부
[Python] For 반복문 본문
For 반복문
기본 구조
리스트 데이터를 for 루프
>>> my_list = [11, 222, 30, 44]
>>> for data in my_list :
>>> print(data)
11
222
30
44
in 안에 들어있는 데이터 스트럭쳐(리스트, 튜플, 딕셔너리, 셋, 스트링)에서 데이터를 하나씩 꺼낸다. 꺼낸 데이터는 for 오른쪽의 변수(data)에 저장된다.
그러므로 결과는 위와 같다.
딕셔너리 데이터를 for 루프 : 기본은 key 값이 뽑힌다. value 값이 필요하면 values() 를 활용해야 한다.
>>> my_phone = {'brand' : 'apple', 'model' : 'iPhone 12', 'color' : 'red', 'year' : 2021}
>>> for data in my_phone :
>>> print(data)
brand
model
color
year'Python > Basic' 카테고리의 다른 글
| [Python] While 반복문 (0) | 2022.04.25 |
|---|---|
| [Python] 반복문에서 Break, Continue (0) | 2022.04.25 |
| [Python] if 조건문 (0) | 2022.04.21 |
| [Python] 논리 연산자 AND, OR (0) | 2022.04.21 |
| [Python] 비교 연산자 (0) | 2022.04.21 |