Given a string, say s='135'
and a list, say A=['1','2','3','4','5','6','7']
, how can I separate the values in the list that are also in 's' (a digit of s) from the other elements and concatenate these other elements. The output in this example should be: A=['1','2','3','4','5','67']
.
Another example:
s='25'
A=['1','2','3','4','5','6','7']
output: A=['1','2','34','5','67']
Is there a way of doing this without any import statements (this is so that I can get a better understanding of Python and how things work)?
I am quite new to programming so any help would be appreciated!
(Please note: This is part of a larger problem that I am trying to solve).
See Question&Answers more detail:os