Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Administrator
/
level3-lesson13-diy2
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
e96d095a
authored
Oct 02, 2022
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
auto save
parent
0a7b0048
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
2 deletions
demo.py
diy2.py
demo.py
0 → 100644
View file @
e96d095a
name
=
[
'王志睿'
,
'葛思诺'
,
'卓民'
]
'''
列表名.pop(2)
列表名.pop(-1)
列表名.remove("卓民")
'''
name
.
pop
(
2
)
#name.pop(-1)
#name.remove('卓民')
print
(
name
)
\ No newline at end of file
diy2.py
View file @
e96d095a
alist
=
[
88
,
75
,
72
,
82
,
90
,
85
,
78
,
91
]
\ No newline at end of file
alist
=
[
88
,
75
,
72
,
82
,
90
,
85
,
78
,
91
]
#获取列表长度
n
=
len
(
alist
)
#i表示第几轮排序
for
i
in
range
(
0
,
n
-
1
):
#j表示索引下标
for
j
in
range
(
0
,
n
-
1
):
#开始比较大小并交换顺序
if
alist
[
j
]
<
alist
[
j
+
1
]:
'''
如果第一个索引下标的值大于后面索引下标的值,就更改下标,更改这个最大值
'''
alist
[
j
],
alist
[
j
+
1
]
=
alist
[
j
+
1
],
alist
[
j
]
print
(
alist
)
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