Keep the evens · احتفظ بالزوجيات
Keep the evens
Filter a list: keep some items and leave the rest out.
Start with an empty list, loop over nums, and .append() each number that passes the test n % 2 == 0. Return the new list after the loop has finished.
احتفظ بالأعداد الزوجية
فلتر قائمة: احتفظ ببعض العناصر واترك الباقي.
ابدأ بقائمة فارغة، تجول فوق nums، و.append() كل رقم يجتاز اختبار n % 2 == 0. أعد القائمة الجديدة بعد انتهاء الحلقة.
Write evens(nums) that returns a new list holding only the even numbers from nums, in the same order. · اكتب evens(nums) ترجع قائمة جديدة تحتوي فقط على الأعداد الزوجية من nums، بنفس الترتيب.
Click Run to see the output here. · اضغط تشغيل لرؤية المخرجات هنا.