समस्या विवरण
आप एक सरणी बना सकते हैं जिसमें स्ट्रिंग के सभी नॉन-डिजिट वर्णों को ट्रैक किया जाए। फिर अंत में इस सरणी को "".join मेथड का उपयोग करके जोड़ें।
उदाहरण
my_str = 'qwerty123asdf32'
non_digits = []
for c in my_str:
if not c.isdigit():
non_digits.append(c)
result = ''.join(non_digits)
print(result)
आउटपुट
qwertyasdf
उदाहरण
आप इसे पायथन लिस्ट कॉम्प्रिहेंशन का उपयोग करके एक ही लाइन में भी प्राप्त कर सकते हैं।
my_str = 'qwerty123asdf32'
result = ''.join([c for c in my_str if not c.isdigit()])
print(result)
आउटपुट
qwertyasdf