Lists ตอบสนองต่อตัวดำเนินการ + และ * คล้ายกับ strings พวกมันหมายถึง concatenation และ repetition ที่นี่ด้วย ยกเว้นว่าผลลัพธ์คือ list ใหม่ ไม่ใช่ string
ในความเป็นจริง lists ตอบสนองต่อ general sequence operations ทั้งหมดที่เราใช้กับ strings ในบทก่อนหน้า:
| Python Expression | Results | Description |
|---|---|---|
| len([1, 2, 3]) | 3 | Length |
| [1, 2, 3] + [4, 5, 6] | [1, 2, 3, 4, 5, 6] | Concatenation |
| ['Hi!'] * 4 | ['Hi!', 'Hi!', 'Hi!', 'Hi!'] | Repetition |
| 3 in [1, 2, 3] | True | Membership |
| for x in [1, 2, 3]: print x, | 1 2 3 | Iteration |