ENع
الدرس 09 · Collections and functions

Comprehensions

لم يُترجم بعد؛ يُعرض باللغة الإنجليزية

A list comprehension builds a new list from an old one in a single expression: square brackets around an expression, a for clause and an optional if clause. Step through big = [n * 10 for n in nums if n > 2] one item at a time: watch for take each value, if test it, and the expression turn the ones that pass into new items, so the new list grows to [40, 50]. Then see the same work written as a plain for loop.

12 دقيقة10 خطوات5 أسئلةBeginner
شكل 9 · تفاعلي
جارٍ تحميل الرسم…
أو ← →

اختبار يتاح بعد الخطوة الأخيرة.