CBSE Class 11 Computer Science
Question 90 of 104
List Manipulation — Question 4
Back to all questions 4
Question Question 4
Ask the user to enter a list containing numbers between 1 and 12. Then replace all of the entries in the list that are greater than 10 with 10.
Solution
l = eval(input("Enter list having numbers between 1 & 12: "))
for i in range(len(l)):
if l[i] > 10:
l[i] = 10
print("List after removing numbers greater than 10:")
print(l)Output
Enter list having numbers between 1 & 12: [1, 3, 15, 8, 20]
List after removing numbers greater than 10:
[1, 3, 10, 8, 10]