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