Run
nums = [5, 8, 2, 3, 9, 44, 21] # Take an empty list to store the filtered items filtered_nums = [] # For each item in the list for n in nums: # Check if the item satisfies the filter condition if n % 2 == 0: # If the item satisfies the conditon, then add it to the filtered list filtered_nums.append(n) # Print the filtered list print(f"Filtered list : {filtered_nums}")
Output