How to remove all the values in a string except for the chosen ones

Viewed 6854

So my code is value = "123456" I want to remove everything except for 2 and 5. the output will be 25 the program should work even the value is changed for example value = "463312" the output will be 2

I tried to use remove() and replace() function. But it didn't work. Doing it on python 3.6.2

6 Answers
Related