Page 233 - Bilgisayar Bilimi | Kur 1
P. 233
10.16. Listeden Eleman Çıkarma
Listeden bir eleman silmek için del komutu kullanılır.
Örnek
>>>a=list(range(10,51,10))
>>>a
[10,20,30,40,50]
>>>del a[2]
>>>a
[10,20,40,50]
Örnek
>>>b=list(range(20))
>>>b
[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19]
>>>del b[5:15]
>>>b
[0,1,2,3,4,15,16,17,18,19]
Örnek
>>>c=list(range(20))
>>>c
[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19]
>>>del c[1],c[18]
>>>c
[0,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18]
10.17. Listeler ve Fonksiyonlar
def sum(lst):
result=0
for item in lst:
result+=item
return result
def make _ zero(lst):
for i in range(len(lst)):
lst[i]=0
def random _ list(n):
232