5. Write a python program to remove all the odd numbers from the number_list variable as in the output below.
The output is:
number_list = [22, 5, 76, 100, 12.3, 9, 88, 7, 13, 57]
Answer: The remaining even numbers in the number_list are: [22, 76, 100, 88]
Answer:
number_list = [22, 5, 76, 100, 12.3, 9, 88, 7, 13, 57] new_number_list = [x for x in number_list if x%2==0] print("The remaining even numbers in the number_list are: ", new_number_list)
More Exercises:
Python String ExercisesMore Numpy Exercises:
Numpy String ExercisesMore Pandas Exercises:
Pandas Series ExercisesMore Tutorials:
Python Installation - Linux (Ubuntu)