Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
bellcode
/
lesson8-3
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
7f001a13
authored
Feb 19, 2023
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
auto save
parent
87be3438
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
0 deletions
s.py
s2.py
s.py
0 → 100644
View file @
7f001a13
1
,
range
(
start
=
0
,
stop
,
step
=
1
)
如
range
(
1
,
5
,
2
)
1.
.
4
,
1
3
for
i
in
range
(
5
):
print
(
i
)
for
i
in
range
(
1
,
5
):
print
(
i
)
for
i
in
range
(
1
,
5
,
2
):
print
(
i
)
for
i
in
xxx
:
2
,
for
循环可以遍历任何序列的项目
语法:
for
i
in
xxx
:
遍历的对象要求是一个迭代对象(可以简单看作一个容器,里面包括很多个元素)
如:
goods
=
[
'可乐'
,
'咖啡'
,
'鸡翅'
,
'冰淇淋'
]
for
i
in
goods
:
print
(
i
)
执行结果:
可乐
咖啡
鸡翅
冰淇淋
\ No newline at end of file
s2.py
0 → 100644
View file @
7f001a13
goods
=
[
'可乐'
,
'咖啡'
,
'鸡翅'
,
'冰淇淋'
]
for
i
in
goods
:
print
(
i
)
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment