You can try this one :
s = "H!i I am f.rom G3?ermany"
l = []
for i in s.split():
k = [j for j in i if j.isalpha()]
for m in i:
if not m.isalpha():
k.append(m)
l.append(''.join(k))
print(' '.join(l))
It will o/p like :
"Hi! I am from. Germany3?
In python 2x you can do it in single line like :
k = ' '.join([filter(str.isalpha,i)+''.join([j for j in i if not j.isalpha()]) for i in s.split()])
1
solved Special characters to the end of sentence [closed]