How can i do a code in python3 that deletes only letters(with def) | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 5

How can i do a code in python3 that deletes only letters(with def)

exemple input: avrvt25gsv57 output: 2557

16th Jul 2018, 6:25 PM
I Am Arthur
I Am Arthur - avatar
2 Answers
+ 7
inp='avrvt25gsv57' print(*[i for i in inp if i.isdigit()],sep='') #if you want to do it with def. def removeLetters(s): return ''.join([i for i in s if i.isdigit()]) print(removeLetters(inp))
16th Jul 2018, 6:54 PM
Louis
Louis - avatar