Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
8c5e190d
Kaydet (Commit)
8c5e190d
authored
Kas 22, 2016
tarafından
Raymond Hettinger
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #28587: Improve list examples in the tutorial
üst
6023d334
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
24 deletions
+20
-24
datastructures.rst
Doc/tutorial/datastructures.rst
+20
-24
No files found.
Doc/tutorial/datastructures.rst
Dosyayı görüntüle @
8c5e190d
...
@@ -99,30 +99,26 @@ objects:
...
@@ -99,30 +99,26 @@ objects:
An example that uses most of the list methods::
An example that uses most of the list methods::
>>> a = [66.25, 333, 333, 1, 1234.5]
>>> fruits = ['orange', 'apple', 'pear', 'banana', 'kiwi', 'apple', 'banana']
>>> print(a.count(333), a.count(66.25), a.count('x'))
>>> fruits.count('apple')
2 1 0
2
>>> a.insert(2, -1)
>>> fruits.count('tangerine')
>>> a.append(333)
0
>>> a
>>> fruits.index('banana')
[66.25, 333, -1, 333, 1, 1234.5, 333]
3
>>> a.index(333)
>>> fruits.index('banana', 4) # Find next banana starting a position 4
1
6
>>> a.index(333, 2) # search for 333 starting at index 2
>>> fruits.reverse()
2
>>> fruits
>>> a.remove(333)
['banana', 'apple', 'kiwi', 'banana', 'pear', 'apple', 'orange']
>>> a
>>> fruits.append('grape')
[66.25, -1, 333, 1, 1234.5, 333]
>>> fruits
>>> a.reverse()
['banana', 'apple', 'kiwi', 'banana', 'pear', 'apple', 'orange', 'grape']
>>> a
>>> fruits.sort()
[333, 1234.5, 1, 333, -1, 66.25]
>>> fruits
>>> a.sort()
['apple', 'apple', 'banana', 'banana', 'grape', 'kiwi', 'orange', 'pear']
>>> a
>>> fruits.pop()
[-1, 1, 66.25, 333, 333, 1234.5]
'pear'
>>> a.pop()
1234.5
>>> a
[-1, 1, 66.25, 333, 333]
You might have noticed that methods like ``insert``, ``remove`` or ``sort`` that
You might have noticed that methods like ``insert``, ``remove`` or ``sort`` that
only modify the list have no return value printed -- they return the default
only modify the list have no return value printed -- they return the default
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment