看板 Python 關於我們 聯絡資訊
原文吃光光 A = [1, 2, 3, 4] B = [5, 6, 7, 8] C = [1, 3, 4, 5, 7] for c in C: try: print(B[A.index(c)]) except: pass Result: 5 7 8 如果是我的話我會這樣寫~ -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 140.138.155.196 (臺灣) ※ 文章網址: https://www.ptt.cc/bbs/Python/M.1599980905.A.5C2.html
oneonesix: 感謝分享 09/14 06:10
jlhc: index time complexity is O(n) ... 09/14 14:20