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 |
Tags
- Algorithm
- Linux
- Java
- DS
- CSS
- javascript
- DB
- MacOS
- MIPS
- web
- while
- php
- html
- for
- data structure
- architecture
- control
- Pipelining
- XML
- computer
- instruction
- Class
- DoM
- DATAPATH
- python
- function
- system
- react
- mysql
- github
Archives
- Today
- Total
YYYEJI
[Python] for문과 while문의 차이점 본문
728x90
for문
반복 횟수가 정해진 경우 자주 사용됩니다.
num = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
total = 0
for i in num:
total += i
print(total)
while문
특정 조건이 만족할 때까지 반복문을 사용할 경우 자주 사용됩니다.
i = 0
while i<10:
i += 1
print(i)
◡̈
'Python' 카테고리의 다른 글
[Python] 집합(Set) 정리 (0) | 2022.10.06 |
---|---|
[Python] 튜플(Tuple) 정리 (0) | 2022.10.06 |
[Python] 반복문 (while문) (0) | 2022.09.29 |
[MacOS] FileNotFoundError: [Errno 2] No such file or directory: 'xxxx.txt' (0) | 2022.09.28 |
[Python] find, startswith, endswith 함수 (0) | 2022.09.26 |