Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
bellcode
/
lesson6-1
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
ffc88026
authored
Mar 08, 2024
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
auto save
parent
26b3b1d4
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
8 deletions
diy.py
diy1.py
diy2.py
diy.py
View file @
ffc88026
# 和你的小伙伴用列表讲讲桃园结义的故事,并说说这其中运用了哪些列表知识:
# 和你的小伙伴用列表讲讲桃园结义的故事,并说说这其中运用了哪些列表知识:
# 来,我给你起个头~
# 来,我给你起个头~
# 从前啊,有三个bro,分别是:刘备、关羽、张飞...
# 从前啊,有三个bro,分别是:刘备、关羽、张飞...
bro1
=
"关羽"
bro2
=
"刘备"
bro3
=
"张飞"
bros
=
[
"刘备"
,
"关羽"
,
"张飞"
]
bros
=
[
"刘备"
,
"关羽"
,
"张飞"
]
bro1
=
[
"关羽"
,
160
,
8.5
]
bro2
=
[
"刘备"
,
161
,
9.1
]
bro3
=
[
"张飞"
,
166
,
8.3
]
bros
[
0
]
=
"关羽"
bros
[
0
]
=
"关羽"
bros
[
1
]
=
"刘备"
bros
[
1
]
=
"刘备"
print
(
bros
)
print
(
bros
)
\ No newline at end of file
\ No newline at end of file
diy1.py
0 → 100644
View file @
ffc88026
s
=
[
'袁术'
,
'夏侯惇'
,
'曹操'
,
'关羽'
]
s
.
remove
(
'关羽'
)
#或者使用 b.pop(3)
#或者使用 b.pop(-1)
print
(
s
)
#关羽上前迎战,战场上除了华雄还有关羽,得把关羽填到a列表中:
a
=
[
'华雄'
]
a
.
insert
(
1
,
'关羽'
)
# 或者使用a.append('关羽')
print
(
a
)
#其实啊,在关羽出战之前,袁术说:“可惜我的大将颜良、文丑不在,不然,就不怕华雄了。”那假如颜良、文丑在场并同时出战,你知道该如何用代码表达么?
a
=
[
'华雄'
]
c
=
[
'颜良'
,
'文丑'
]
a
.
extend
(
c
)
print
(
a
)
\ No newline at end of file
diy2.py
0 → 100644
View file @
ffc88026
a
=
[
'吕布'
]
b
=
[
'袁术'
,
'公孙瓒'
,
'关羽'
,
'张飞'
,
'刘备'
,
'曹操'
]
a
.
extend
(
b
[
2
:
5
])
print
(
a
)
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