[第一題]計算有多少個句子是以 . 結尾 的另種方式
2021/02/23 05:13 下午
A
觀看數:6
回答數:1
收藏數:0
想請問我第一題使用另種方式回答 為何要指定一個空的list 再使用len才是正確數值 如果將endswith('.')的句子直接餵入 (如 # 的部分) 結果會是134 dotsen =[] for i in all_review: if i.endswith('.') == True: dotsen.append(i) #不能直接用 的理由 # for i in all_review: # if i.endswith('.') == True: # dotsen= i #算出來是 134 感謝您!!!