Vị trí element trong list (sequence) dùng method index(). Tìm first occurrence.
Ví dụ
>>> L1 = [45, 32, 100, 10, 24, 56] >>> L1.index(24) 4
Lưu ý: Nếu element không có → raise ValueError. Dùng try/except hoặc if item in list trước.
Vị trí element trong list (sequence) dùng method index(). Tìm first occurrence.
>>> L1 = [45, 32, 100, 10, 24, 56] >>> L1.index(24) 4
Lưu ý: Nếu element không có → raise ValueError. Dùng try/except hoặc if item in list trước.