Commit f028ae70 by BellCodeEditor

save project

parent 8dfbd7d6
Showing with 28 additions and 7 deletions
# 和你的小伙伴讲讲史上有名的三英战吕布的故事。然后完成下面挑战,并说说列表切片是什么,怎么用: #删除
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
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:])
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment