I tried to replace every digit in a string with # and to remove all other digits. I not getting answer in list format.
import re
def replace(str):
for i in str:
if 48 <= ord(i) >= 57:
print(i.replace(i, "#"))
else:
print(i.replace(i, " "))
str_1 = "adgf*^%12345"
replace(str_1)
Aucun commentaire:
Enregistrer un commentaire