Now I have this :
str = " s tr & &^ 23G7/*%45afju657**(%^#%$!!fdf"
str = ''.join(e for e in str if e.isalnum())
str = ''.join(('...', str, '...'))
Can I combine them like :
str = ''.join(('...', e for e in str if e.isalnum(), '...'))
You can use format there
s = "...{}...".format(''.join(e for e in s if e.isalnum()))
As a side note, do not name your string as str as it shadows the builtin
Apart from that, if you really really want to use join twice, you can write it as
''.join(('...', ''.join(e for e in s if e.isalnum()), '...'))
But it is not a good idea. Why use a nuclear bomb to kill a mosquito!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With