python - Removing only alpha duplicates -


in python, remove duplicate letters string, not numbers or spaces. came with:

result = [] seen = set() char in string:     if char not in seen:         seen.add(char)         result.append(char) return "".join(result) 

but makes:

>>> delete_duplicate_letters("13 men wounded in explosion yesterday around 3:00pm.") 13 menwroudiaxplsyt:0. 

when want:

>>> delete_duplicate_letters("13 men wounded in explosion yesterday around 3:00pm.") 13 men wr oud xpls yt 3:00. 

i've tried use letter instead of char, isalpha() function , if int statements etc couldn't work.

try this:

result = "" char in string:     if not (char.isalpha() , char in result):         result += char 

Comments

Popular posts from this blog

Change php variable from jquery value using ajax (same page) -

Pull out data related to my apps from Android Play Store and iOS App Store -

How can I fetch data from a web server in an android application? -