аватар question@mail.ru · 01.01.1970 03:00

How to find symbols from the motorcade ('!', ',', '?') In the line and remove them?

there is a motorcade:

  a = ( '!' ,  ',' ,  ''? ')     

and the line

  Dasd, Sadarg! Ada    

How can you find characters from a motorcade in a line and remove them?

аватар answer@mail.ru · 01.01.1970 03:00

For example, this:

   & gt; & gt; & gt;  a = ( ''! ', ' ',' ,  ''? ')   & gt; & gt;  s =  'dasd, sadarg! ada'    & gt; & gt; & gt;   ''  .join ( filter  ( lambda  x: x  not   in  a, s))   'dasdsadargada'   

   & gt; & gt; & gt;   ''  .join (x  in  s  if  x  in  a)   'dasdsadargada'      

and in the other case we do not remove the symbols from the old line, but create a new line, which includes only those characters of the old line that satisfy the condition "" The X symbol is not included in the motorcade A "" (X not in A).

Latest

Similar