Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
bellcode
/
lesson6-4
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
f028ae70
authored
Jun 22, 2024
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
save project
parent
8dfbd7d6
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
7 deletions
diy.py
sel1.py
diy.py
View file @
f028ae70
# 和你的小伙伴讲讲史上有名的三英战吕布的故事。然后完成下面挑战,并说说列表切片是什么,怎么用:
#删除
a
=
[
"张飞"
,
"刘备"
,
"曹操"
,
"关羽"
,
"诸葛亮"
]
# 省略繁杂情节,刘关张三人一起冲入战场,围攻吕布:
a
.
remove
(
"诸葛亮"
)
a
=
[
'吕布'
]
a
.
pop
(
3
)
b
=
[
'袁术'
,
'公孙瓒'
,
'关羽'
,
'张飞'
,
'刘备'
,
'曹操'
]
a
.
pop
(
-
2
)
print
(
a
)
#添加
a
=
[
"张飞"
,
"刘备"
,
"关羽"
]
a
.
insert
(
1
,
"纪宇辰"
)
a
.
append
(
"张博裕"
)
print
(
a
)
#列表添加
a
=
[
"纪宇辰"
,
"张博裕"
]
b
=
[
"曹操"
,
"诸葛亮"
,
"董卓"
]
c
=
[
"张飞"
,
"刘备"
,
"关羽"
,
"袁术"
,
"公孙瓒"
]
a
.
extend
(
b
)
a
.
extend
(
c
[
1
:
5
])
print
(
a
)
\ No newline at end of file
sel1.py
0 → 100644
View file @
f028ae70
name
=
input
(
"你叫什么名字"
)
power
=
int
(
input
(
"你的臂力值"
))
c
=
[
"张飞"
,
30
,
"刘备"
,
45
,
"关羽"
,
60
,
"袁术"
,
80
,
"公孙瓒"
,
97
]
for
i
in
range
(
len
(
c
)):
if
i
%
2
==
1
and
c
[
i
]
>=
power
:
c
.
insert
(
i
-
1
,
name
)
c
.
insert
(
i
,
power
)
break
print
(
c
[
-
5
:])
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