Metod remove

Metod remove gosterilen elementi siyahidan silir. Metodun parametrinde silmelimiz istediyimiz element teyin olunur. Metod siyahinin ozunu deyisir. Netice olaraq None qaytarilir. Movcud olmayan bir elementi silmeq cehdi istisnanin atilmasina sebeb olacaq.

Sintaksis

pythonsiyahi.remove(ne silmek isteyirik)

Misal

Gelin remove metodu ile siyahimizdan 'ef' elementini silek:

pythonlst = ['ab', 'cd', 'ef', 'gh']

lst.remove('ef')
print(lst)

Kodu isletmenin neticesi:

python['ab', 'cd', 'gh']

Misal

Indi ise gelin siyahida olmayan bir elementi silmeye cehd edek:

pythonlst = ['ab', 'cd', 'ef', 'gh']

lst.remove('12')
print(lst)

Kodu isletmenin neticesi:

errorValueError: list.remove(x): x not in list

Baxin da

  • metod clear,
    siyahinin butun elementlerini silir
  • metod pop,
    elementi indeksine gore silir
  • metod append,
    elementi siyahinin sonuna elave edir