เพื่อแปลง tuple เป็น array (list) คุณสามารถใช้ list constructor โดยตรงได้
ตัวอย่าง
x = (1, 2, 3) y = list(x) print(y)
ผลลัพธ์
[1, 2, 3]
ตัวอย่าง
หากคุณมี multi-level tuple และต้องการ flat array คุณสามารถทำได้ดังนี้:
z = ((1, 2, 3), (4, 5)) y = [a for b in z for a in b] print(y)
ผลลัพธ์
[1, 2, 3, 4, 5]