Commit e96d095a by BellCodeEditor

auto save

parent 0a7b0048
Showing with 25 additions and 2 deletions
name = ['王志睿','葛思诺','卓民']
'''
列表名.pop(2)
列表名.pop(-1)
列表名.remove("卓民")
'''
name.pop(2)
#name.pop(-1)
#name.remove('卓民')
print(name)
\ No newline at end of file
alist = [88, 75, 72, 82, 90, 85, 78, 91]
\ No newline at end of file
alist = [88, 75, 72, 82, 90, 85, 78, 91]
#获取列表长度
n = len(alist)
#i表示第几轮排序
for i in range(0,n-1):
#j表示索引下标
for j in range(0,n-1):
#开始比较大小并交换顺序
if alist[j]<alist[j+1]:
'''
如果第一个索引下标的值大于后面索引下标的值,就更改下标,更改这个最大值
'''
alist[j],alist[j+1]=alist[j+1],alist[j]
print(alist)
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