看板
[ Python ]
討論串[問題] Python新手 for迴圈問題
共 5 篇文章
內容預覽:
各位前輩大家好,我是剛接觸python不久的新人,目前練習到for迴圈時有點卡關,想請教一下各位前輩. 我有三個List. ListA=[“Apple”,“food”,“Iron”]. ListB=[“x”,“z”,“on”]. ListC=[]. 今天我想知道ListA中的字串是否有包含ListB
(還有275個字)
內容預覽:
稍微修改一下. if len(ListA) != len(ListB):. assert 'ListA 長度跟 ListB 長度不一致'. for a_index, a_str in enumerate(ListA):. b_str = ListB[a_index]. if b_str in a_s
(還有350個字)
內容預覽:
只需要一個for即可.. listA = ['Apple', 'food', 'Iron']. listB = ['x','z','on']. listC = []. for x,y in enumerate(listA):. if listB[x] in listA[x]:. listC.appe
(還有17個字)