第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

為 Python 中的列表中的每個子列表返回大于 k 的數(shù)字索引

為 Python 中的列表中的每個子列表返回大于 k 的數(shù)字索引

躍然一笑 2023-04-18 17:33:30
輸入:查找子列表中大于 50 的數(shù)字的索引a = [[10,40,90],[120,30,200],[70,90,100]]期望的輸出:index_of_values_greater_than_50 = [[2][0,2][0,1,2]]
查看完整描述

2 回答

?
慕姐8265434

TA貢獻1813條經(jīng)驗 獲得超2個贊

output_list = []


a = [[10,40,90],[120,30,200],[70,90,100]]


for array in a:

   counter = 0

   new_list = []

   while counter < len(array):

      if array[counter] > 50:

         new_list.append(counter)

      counter += 1

   output_list.append(new_list)


print(output_list)

輸出(根據(jù)需要):


[[2], [0, 2], [0, 1, 2]]   


查看完整回答
反對 回復(fù) 2023-04-18
?
慕少森

TA貢獻2019條經(jīng)驗 獲得超9個贊

index_of_values_greater_than_50 = []

for x in a:

 temp = [i for i, y in enumerate(x) if (y>50)

 index_of_values_greater_than_50.append(temp)


查看完整回答
反對 回復(fù) 2023-04-18
  • 2 回答
  • 0 關(guān)注
  • 127 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號