list 四大特色:
- 有序號
- 可重複
- 可不同型別
- 可更改組的資料
有兩種方式可以表示list 陣列
第一種使用["第一筆資料","第二筆資料","第三筆資料","第N筆資料" ]
Member_id = ["MBA", "MBB", "MBC","MBD"]
print(Member_id)
第二種使用 list(("第一筆資料","第二筆資料","第三筆資料","第N筆資料"))
student_id=list(("B001","B002","B003","B004"))
print(student_id)
1.有序號
#1.有序號 (每一筆資料都有序號,序號由0開始編))
#["序號=0","序號=1","序號=2","序號=3"]
member_id=["A001","A002","A003","A004"]
print(member_id[2])
student_id=list(("B001","B002","B003","B004"))
print(student_id[0])
2.可重複
name=list(("AAA","BBB","CCC","BBB"))
print(name)
3可不同型別 (可存入字串、整數、浮點數等等不同型別)
#3可不同型別
member=["123",150,"123","AAA",1.5]
print(member)
4.可更改組的資料
#4.可更改組的資料
number=list(("AAA","BBB","CCC","BBB"))
print(number)
number[3]="DDD"
print(number)
Yiru@Studio - 關於我 - 意如