Replacing the value in the list
List
a=[5,6,7,5,8,7]
replace 7 with 3
required output
[5,6,3,5,8,7]
Condition?
With out slice?
Replacing the value in the list
List
a=[5,6,7,5,8,7]
replace 7 with 3
required output
[5,6,3,5,8,7]
Condition?
With out slice?
You can use a list comprehension:
[3 if x==7 else x for x in a]