Re: [問題] 多個list快速比對

作者: HenryLiKing (HenryLiKing)   2020-09-13 15:08:22
原文吃光光
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
如果是我的話我會這樣寫~
作者: oneonesix (小韓)   2020-09-14 06:10:00
感謝分享
作者: jlhc (H)   2020-09-14 14:20:00
index time complexity is O(n) ...

Links booklink

Contact Us: admin [ a t ] ucptt.com