Ask the use to enter a list containing number between 1 and 12, then replace all the entries in the list that are  greater than 10 with 10

"> PYTHON PROGRAM TO ENTER A LIST CONTAINING NUMBER BETWEEN 1 AND 12 THEN REPLACE ALL THE ENTRIES IN THE LIST THAT ARE GREATER THAN 10 WITH 10

Programming Example

Ask the use to enter a list containing number between 1 and 12, then replace all the entries in the list that are  greater than 10 with 10

Solution

mylist=eval(input("Enter any List"))
print("Before Replace list is ",mylist)
a=0
for b in mylist:
    if b>10:
        mylist[a]=10
    a=a+1
print("After Replace list is ",mylist)
Output

Enter any List[4,12,5,10,11,7]

Before Replace list is  [4, 12, 5, 10, 11, 7]

After Replace list is  [4, 10, 5, 10, 10, 7]

CCC Online Test 2021 CCC Practice Test Hindi Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) Best Java Training Institute in Prayagraj (Allahabad) Best Python Training Institute in Prayagraj (Allahabad) O Level NIELIT Study material and Quiz Bank SSC Railway TET UPTET Question Bank career counselling in allahabad Sarkari Naukari Notification Best Website and Software Company in Allahabad Website development Company in Allahabad