Page 232 - Bilgisayar Bilimi | Kur 1
P. 232

Örnek

              lst=[10,20,30,40,50,60,70,80]
              print(lst) # Print the list
              lst[2:5]=[‹a›, ‹b›, ‹c›] # Replace [30, 40, 50] segment with [‹a›, v‹b›,
             ‹c›]
              print(lst)

              print(‹==================›)
              lst=[10,20,30,40,50,60,70,80]
              print(lst) # Print the list

              lst[2:6]=[‹a›, ‹b›] # Replace [30, 40, 50, 60] segment with [‹a›, ‹b›]
              print(lst)
              print(‹==================›)

              lst=[10,20,30,40,50,60,70,80]
              print(lst) # Print the list
              lst[2:2]=[‹a›, ‹b›, ‹c›] # Insert [‹a›, ‹b›, ‹c›] segment at index 2

              print(lst)
              print(‹==================›)
              lst=[10,20,30,40,50,60,70,80]

              print(lst) # Print the list
              lst[2:5]=[] # Replace [30, 40, 50] segment with [] (delete the
             segment)
              print(lst)


               Ekran Çıktısı

              [10, 20, 30, 40, 50, 60, 70, 80]
              [10, 20, ‘a’, ‘b’, ‘c’, 60, 70, 80]
              ================
              [10, 20, 30, 40, 50, 60, 70, 80]
              [10, 20, ‘a’, ‘b’, 70, 80]
              ================

              [10, 20, 30, 40, 50, 60, 70, 80]
              [10, 20, ‘a’, ‘b’, ‘c’, 30, 40, 50, 60, 70, 80]
              ================
              [10, 20, 30, 40, 50, 60, 70, 80]
              [10, 20, 60, 70, 80]

              ================

                                                                                                     231
   227   228   229   230   231   232   233   234   235   236   237