logo
Loading...

[第一題]計算有多少個句子是以 . 結尾 的另種方式 - Cupoy

想請問我第一題使用另種方式回答為何要指定一個空的list再使用len才是正確數值如果將endswit...

[第一題]計算有多少個句子是以 . 結尾 的另種方式

2021/02/23 下午 05:13
Python 文字處理函數介紹
A
觀看數:16
回答數: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 感謝您!!!

回答列表