KnowledgeBoat Logo
|

Robotics & Artificial Intelligence

Write a program to delete/remove all the numbers less than 10 from the list.

Python Control Flow

1 Like

Answer

numbers = [5, 12, 3, 20, 8, 15, 2, 30]
new_list = []

for i in numbers:
    if i >= 10:
        new_list.append(i)

print("List after removing numbers less than 10:", new_list)

Output

List after removing numbers less than 10: [12, 20, 15, 30]

Answered By

2 Likes


Related Questions