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
9f047b56
authored
Aug 11, 2022
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
save project
parent
c0ec29e5
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
9 deletions
diy.py
diy.py
View file @
9f047b56
# 和你的小伙伴讲讲史上有名的三英战吕布的故事。然后完成下面挑战,并说说列表切片是什么,怎么用:
list_a
=
[
'留情'
,
13
]
while
True
:
# 省略繁杂情节,刘关张三人一起冲入战场,围攻吕布:
name
=
input
(
"请输入你的姓名:"
)
a
=
[
'吕布'
]
power
=
input
(
"请输入你的臂力值:"
)
b
=
[
'袁术'
,
'公孙瓒'
,
'关羽'
,
'张飞'
,
'刘备'
,
'曹操'
]
i
=
1
a
.
extend
(
b
[
2
:
5
])
while
int
(
power
)
>
list_a
[
i
]:
print
(
a
)
for
i
in
range
(
len
(
list_a
)):
if
i
%
2
==
1
and
list_a
[
i
]
>=
int
(
power
):
list_a
.
insert
(
i
-
1
,
name
)
list_a
.
insert
(
i
,
int
(
power
))
print
(
list_a
)
break
list_a
.
append
(
name
)
list_a
.
append
(
int
(
power
))
print
(
list_a
)
# for i in range(len(list_a)):
# if i%2==1 and list_a[i]>=int(power):
# list_a.insert(i-1,name)
# list_a.insert(i,int(power))
# print(list_a)
# break
# # elif i%2==1 and list_a[i]<int(power):
# # list_a.append(name)
# # list_a.append(int(power))
# # print(list_a)
# # break
\ 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