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
f3e9a736
authored
Jan 15, 2021
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
auto save
parent
e64f1c1c
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
33 additions
and
17 deletions
1.py
bro.py
t1.py
test.py
1.py
View file @
f3e9a736
#臂力挑战赛
#快用你机灵的小脑瓜想想,如何将刘强和他的臂力值自动插入到hero列表中?
name
=
input
(
"请输入姓名:"
)
power
=
int
(
input
(
"请输入臂力值:"
))
name
=
"张三"
power
=
99
hero
=
[
'赵一'
,
30
,
'丁二'
,
37
,
'孙五'
,
52
,
'王猛'
,
89
,
'周亮'
,
98
]
for
i
in
range
(
len
(
hero
)):
if
i
%
2
==
1
and
hero
[
i
]
>=
power
:
hero
.
insert
(
i
-
1
,
name
)
hero
.
insert
(
i
,
power
)
break
s
=
hero
[
-
6
:]
print
(
s
)
# s = hero[-6:]
# print(s)
print
(
hero
)
...
...
bro.py
0 → 100644
View file @
f3e9a736
#列表的基本操作
bros
=
[
"刘备"
,
"关羽"
,
"张飞"
]
bros
[
1
]
=
"刘备"
bros
[
0
]
=
"关羽"
print
(
bros
)
#列表的删除:pop()/remove()
b
=
[
'袁术'
,
'夏侯惇'
,
'曹操'
,
'关羽'
]
#b.pop(3)
#b.pop(-1)
b
.
remove
(
"关羽"
)
print
(
b
)
#列表的增加:insert()\extend()\apend()
a
=
[
'华雄'
]
c
=
[
'颜良'
,
'文丑'
]
a
.
extend
(
c
)
print
(
a
)
#切片:
d
=
[
'吕布'
]
e
=
[
'袁术'
,
'公孙瓒'
,
'关羽'
,
'张飞'
,
'刘备'
,
'曹操'
]
f
=
e
[
2
:
5
]
d
.
extend
(
f
)
print
(
d
)
t1.py
deleted
100644 → 0
View file @
e64f1c1c
name
=
"kar98k"
power
=
99
hero
=
[
'丙三'
,
19
,
'丁二'
,
47
,
'孙五'
,
55
,
'王猛'
,
67
,
'周亮'
,
89
,
'赵一'
,
97
]
for
i
in
range
(
len
(
hero
)):
if
i
%
2
==
1
and
hero
[
i
]
>=
power
:
hero
.
insert
(
i
-
1
,
name
)
hero
.
insert
(
i
,
power
)
break
s
=
hero
[
-
6
:]
print
(
s
)
\ No newline at end of file
test.py
View file @
f3e9a736
name
=
"kar98k"
name
=
'kar98k'
power
=
99
hero
=
[
'丙三'
,
19
,
'丁二'
,
47
,
'孙五'
,
55
,
'王猛'
,
67
,
'周亮'
,
89
,
'赵一'
,
97
]
hero
=
[
'丙三'
,
19
,
'丁二'
,
47
,
'孙五'
,
55
,
'王猛'
,
67
,
'周亮'
,
89
,
'赵一'
,
100
]
for
i
in
range
(
len
(
hero
)):
if
i
%
2
==
1
and
hero
[
i
]
>=
power
:
hero
.
insert
(
i
-
1
,
name
)
...
...
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