We can easily sort out the special characters from the given string. To do so, we need to compare the special characters (excepts (a-z) & (A-Z)) with the ASCII value. The character whose value does not lie in the range of alphabets, we will remove those characters from our string.
Let’s dig into the program directly.
r = ""
for i in str:
if (i >= 'A' and i <= 'Z') or (i >= 'a' and i <= 'z'):
r += i
str = "$My*N;a.me.Is, G'a^vi.n?"
And the program should produce an output