只是想說說最近 youtube 有直播獵人,不間斷真的好讚
看著看著留言區出現「下不整白」就是「下集不看,整季白看」
獵人配鐵人賽,留言區看到有人明天要期末考,我就安心了
倒數了,早沒庫存 顆顆顆
L=[3,6,9,12,15]
我們可以利用 del 來刪除串列裡面的東西
舉例:
del L[2]
print(L)
>>>
[3,6,12,15]
a = [3,6,9]
b = [2,5,8.5,"hello"]
c = []
e = a + b
>>> e = [3,6,9,2,5,8.5,"hello"]
b = [2,5,8.5,"hello"]
y = b[1:3]
print(y)
>>>
[5, 8.5]
d = [16, [a,b]]
a = [3,6,9]
b = [2,5,8.5,"hello"]
z = d[1][0][1]
>>>
6
首先d[1] =>[a,b]
d[0] => [a]
d[1] => 6
1個 list 不管 + 多少 就是 1 個 list
加號單純是串接兩個串列內容
ex : [1,2,3,4,5] + [6,7,8,9]
=> [1,2,3,4,5,6,7,8,9] 1 個 list
1個 list * 多少 還是 1 個 list
重複內容 整串為單位 並非元素
print(3*[1,2,3])
=> [1, 2, 3, 1, 2, 3, 1, 2, 3]
串列可以比較 >, <, ==, !=, >=,<=
[1,2.5,'x']==['x',2.5,1]
>>>
False
位子必須一模一樣 ,才會是 True
索引 片段運算子 (切片?)
L = [5,10,15,20,25,30,35,40,45,50]
L [1:5]
=> [10,15,20,25]
L = [2:-2]
=> [15,20,25,30,35,40]
list 建構
listc = [i for i in range(10)]
print(listc)
>>>
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
listc2 = [j+3 for j in range(10)]
print(listc2)
>>>
[3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
len 串列長度
print(len([1,3,5,7,9]))
=>5
max 串列中最大值
print(max([1,3,5,7,9]))
=>9
min 串列中最小值
print(min([1,3,5,7,9]))
=>1
sum 串列總和
print(sum([1,3,5,7,9]))
=>25