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 |
Tags
- nan
- append()
- list
- analizer
- IN
- del
- Dictionary
- DataFrame
- Machine Learning
- dendrogram
- string
- data
- elbow method
- 최솟값
- hierarchical_clustering
- function
- insert()
- pandas
- len()
- wcss
- 반복문
- count()
- sklearn
- 최댓값
- matplotlib
- 덴드로그램
- Python
- DataAccess
- numpy
- 분류 결과표
Archives
- Today
- Total
개발공부
[Python] 반복문에서 Break, Continue 본문
Break
- 자신을 감싸고 있는 루프의 {} 괄호를 벗어난다. for 반복문이나 while 반복문에서 쓰인다.
예제
>>fruits = ['사과', '배', '망고', '바나나', '수박']
>>
>>for name in fruits :
>> print(name)
>> if name == '망고' :
>> print('Hello')
>> break
>> print('Bye')
>>print('Nice')
사과
배
망고
Hello
Nice
fruits 리스트에서 망고가 출력되면 break가 실행되어 for 반복문을 빠져나가게 되어
Bye는 출력이 되지 않고 바로 Nice가 출력된다.
Continue
- 이번 루프를 뛰어넘고 다음 순서로 돌아간다.
예제
>>for name in fruits :
>> if name == '망고' :
>> continue
>> print(name)
>>print('Nice')
사과
배
바나나
수박
Nice
fruits 리스트 name에 망고가 들어가면 continue가 실행되어 name이 출력되지 않고 바로 다음으로 넘어간다.
'Python > Basic' 카테고리의 다른 글
| [Python] 숫자 리스트를 만들어주는 range() 함수 (0) | 2022.04.25 |
|---|---|
| [Python] While 반복문 (0) | 2022.04.25 |
| [Python] For 반복문 (0) | 2022.04.25 |
| [Python] if 조건문 (0) | 2022.04.21 |
| [Python] 논리 연산자 AND, OR (0) | 2022.04.21 |