FAQ
Hi all,

I would like deleting specific characters from a string.
As an example, I would like to delete all of the '@' '&' in the string
'You are ben at orange?enter&your&code' so that it becomes
'benorange?enteryourcode'.

So far I have been doing it like:
str = 'You are ben at orange?enter&your&code'
str = ''.join([ c for c in str if c not in ('@', '&')])

but that looks so ugly.. I am hoping to see nicer examples to acheive
the above..

Thanks.
Ben.

Search Discussions

Discussion Posts

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 1 of 31 | next ›
Discussion Overview
grouppython-list @
categoriespython
postedJul 9, '03 at 7:12a
activeJul 11, '03 at 2:49p
posts31
users15
websitepython.org

People

Translate

site design / logo © 2022 Grokbase