From 06c386004e7ceb40ecff8b31c001bf2796b51de6 Mon Sep 17 00:00:00 2001 From: BellCodeEditor <bellcode_dev@bell.ai> Date: Fri, 30 Jul 2021 15:29:31 +0800 Subject: [PATCH] save project --- diy.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/diy.py b/diy.py index 93889f1..c8e5561 100644 --- a/diy.py +++ b/diy.py @@ -1,12 +1,16 @@ # 臂力挑战赛 # 快用你机灵的小脑瓜想想,如何将刘强和他的臂力值自动插入到hero列表中? name='刘强' -power=66 +power=100 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) + if i%2==1 and hero[i]<power: + hero.insert(len(hero),name) + hero.insert(len(hero)+1,power) + else : + if i%2==1 and hero[i]>=power: + hero.insert(i-1,name) + hero.insert(i,power) print(hero) print(hero[len(hero)-2:len(hero)-7:-2]) \ No newline at end of file -- libgit2 0.25.0