Skip to content
Navigation Menu
Sign in
Products
Platform
GitHub
Repository hosting, code review, and collaboration
Copilot
AI coding agent for tasks, projects, and automated work
Build & Ship
Actions
CI/CD and automation
Code Quality
Quality analysis, fixes, and enforcement
Codespaces
Cloud development environments
Secure
Code Security
Vulnerability detection and remediation
Secret Protection
Secret scanning and leak prevention
All Features
Developers
Learn
Documentation
Training
Certifications
Build
Build with Copilot
Customize Copilot
Integrations
Explore
Trending repos
GitHub Sponsors
Developer articles
Changelog
Changelog
Your source for the latest features, improvements, and fixes across GitHub products, all in one place.
Businesses
By Stage
Enterprises
Team
Startups
Nonprofits
By Industry
Healthcare
Financial services
Manufacturing
Government
See all industries
Evaluate GitHub
Why GitHub
Customer Stories
Business insights
Trust Center
Add-ons
GitHub Advanced Security
Enterprise-grade code security
Copilot for business
Enterprise-grade AI features
Premium Support
Enterprise-grade 24/7 support
Resources
Learn & Connect
Documentation
Resource center
Blog
Events & webinars
Community Forum
Customer Stories
Integrations
Support
Customer support
Training
GitHub Status
Company
About
Partners
Changelog
GitHub Universe
GitHub Universe
The event for developers, by developers — talks, workshops, and what’s next for GitHub.
Pricing
Search
/
Sign in
Sign up
Appearance settings
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
khl2bb
opensource-class
Repository navigation
Code
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
More
items
Files
Expand file tree
master
Breadcrumbs
opensource-class
/
python_basic
/
loop.py
Copy path
Blame
More file actions
Blame
More file actions
Latest commit
History
History
History
32 lines (28 loc) · 1.27 KB
master
Breadcrumbs
opensource-class
/
python_basic
/
loop.py
Copy path
Top
File metadata and controls
Code
Blame
32 lines (28 loc) · 1.27 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
32
# -*- coding: utf-8 -*-
count
=
0
# 1. while [조건식] - 조건식이 만족할 때 까지 반복한다.
# 조건식 = count 가 10보다 작을때 블럭 실행
while
count
<
10
:
# 1.1. count 를 출력
print
(
"while count="
+
str
(
count
))
# 1.2. count 가 0 에서 시작해서 반복할때마다 1씩 증가한다. 10번 반복하고 while문을 빠져나간다.
count
=
count
+
1
# 2. for 개별요소 in 요소들 - 특정 요소들의 범위내에서 개별요소 단위로 반복하고자 할 때 사용한다.
# 2.1. 문자열 선언
chars
=
"abcdefg"
# 2.2. 문자열 abcdefg 를 한문자씩 반복하면서 문자요소 하나하나를 꺼내서 c 변수에 담는다.
for
c
in
chars
:
# 2.3. 문자 한개단위씩 출력
print
(
"for 1 :"
+
c
)
# 3.1. 문자열로 된 리스트(일종의 배열) 선언
array
=
[
"Hello "
,
"I "
,
"am "
,
"Python"
]
# 3.2. 4개의 문자열을 가진 리스트를 반복하면서 문자열단위로 char 변수에 담는다
for
char
in
array
:
# 3.3. char 문자열 단위로 출력
print
(
"for 2 :"
+
char
)
# 4.1. 3.2와 동일
for
chars
in
array
:
# 4.2 char 에 담은 문자열을 문자 하나씩 꺼내서 c 변수에 담는다
for
c
in
chars
:
# 4.3 문자 하나씩 출력
print
(
"for 3 :"
+
c
)
You can’t perform that action at this time.