Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Administrator
/
lesson5_7
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
634e3a2d
authored
Jun 05, 2021
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
save project
parent
3551c6dd
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
17 deletions
diy2.py
diy2.py
View file @
634e3a2d
#从前啊,有三个bro,分别是:
#注意这里开始,字符串用单引号哦
bro1
=
"刘备"
#残暴不仁的董卓引起大臣们愤恨不平,曹操就想借助群雄的力量讨伐董卓。
bro2
=
"关羽"
#董卓也不是吃素的,收到消息就召集众将,这时,华雄自告奋勇要当先锋。
bro3
=
"张飞"
#董卓见华雄生得威武,便拨给他兵马,令他前去迎敌。
#他们来到了桃园准备结拜
#华雄到达盟军阵前挑战,无人可敌,诸侯们大惊失色。
bros
=
[
"刘备"
,
"关羽"
,
"张飞"
]
#这时还是无名小卒的关羽上前请战,请从b列表中删掉“关羽”,用三种方法哦。
#酒也准备好了,誓词也准备好了,得排个辈分,三人的信息卡是这样的:
b
=
[
'袁术'
,
'夏侯惇'
,
'曹操'
,
'关羽'
]
bro1
=
[
"刘备"
,
161
,
9.1
]
b
.
remove
(
'关羽'
)
bro2
=
[
"关羽"
,
160
,
8.5
]
#或者使用 b.pop(3)
bro3
=
[
"张飞"
,
166
,
8.3
]
#或者使用 b.pop(-1)
#虽然呢,看起来关羽最年长,但是刘备的综合水平最强,所以,关羽一抱拳,甘为老二,刘备就成了大哥。
print
(
b
)
#结拜,大哥自然得站在C位,所以把列表中的刘备替换为关羽,关羽替换为刘备:
\ No newline at end of file
bros
[
0
]
=
"关羽"
bros
[
1
]
=
"刘备"
#这时打印出列表:
print
(
bros
)
#辈分也排完了,三人顺利结拜,讲出誓言:念刘备、关羽、张飞,虽然异姓,既结为兄弟,则同心协力,救困扶危,上报国家,下安黎庶;不求同年同月同日生,只愿同年同月同日死。皇天后土,实鉴此心;背义忘恩,天人共戮! 这就是桃园结义的故事~
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