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
799b05b0
Kaydet (Commit)
799b05b0
authored
Eyl 01, 2015
tarafından
Raymond Hettinger
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Sade Fark
merge
üst
c994cd21
502bf511
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
11 deletions
+11
-11
datastructures.rst
Doc/tutorial/datastructures.rst
+11
-11
No files found.
Doc/tutorial/datastructures.rst
Dosyayı görüntüle @
799b05b0
...
@@ -612,18 +612,18 @@ returns a new sorted list while leaving the source unaltered. ::
...
@@ -612,18 +612,18 @@ returns a new sorted list while leaving the source unaltered. ::
orange
orange
pear
pear
To change a sequence you are iterating over while inside the loop (for
It is sometimes tempting to change a list while you are looping over it;
example to duplicate certain items), it is recommended that you first make
however, it is often simpler and safer to create a new list instead. ::
a copy. Looping over a sequence does not implicitly make a copy. The slice
notation makes this especially convenient::
>>> import math
>>> raw_data = [56.2, float('NaN'), 51.7, 55.3, 52.5, float('NaN'), 47.8]
>>>
words = ['cat', 'window', 'defenestrate'
]
>>>
filtered_data = [
]
>>> for
w in words[:]: # Loop over a slice copy of the entire list.
>>> for
value in raw_data:
... if
len(w) > 6
:
... if
not math.isnan(value)
:
...
words.insert(0, w
)
...
filtered_data.append(value
)
...
...
>>>
words
>>>
filtered_data
[
'defenestrate', 'cat', 'window', 'defenestrate'
]
[
56.2, 51.7, 55.3, 52.5, 47.8
]
.. _tut-conditions:
.. _tut-conditions:
...
...
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