列表資料型別
列表包含以逗號分隔幷包含在方括號[]中的專案。列表幾乎與 C 中的陣列類似。一個區別是屬於列表的所有專案可以是不同的資料型別。
list = [123,'abcd',10.2,'d'] #can be a array of any data type or single data type.
list1 = ['hello','world']
print(list) #will ouput whole list. [123,'abcd',10.2,'d']
print(list[0:2]) #will output first two element of list. [123,'abcd']
print(list1 * 2) #will gave list1 two times. ['hello','world','hello','world']
print(list + list1) #will gave concatenation of both the lists. [123,'abcd',10.2,'d','hello','world']