As a newbie programmer

Extraction of Numbers @ Dcoder

Dcoder icon

Problem: Ron is schizophrenic and sees random digits hidden in words. He thinks it means something and someone is trying to secretly communicate with him. He wants to extract those digits from the words and see if they form a message. Harry really wants to help him but couldn't think of a way. But, Harry finally realized that if he somehow helps Ron in extracting those digits, Ron will finally realize that they don't mean anything and are just his delusions. He asked Ron to write down all the words that he sees. Help Harry by extracting the digits from these words. Input: First line contains N, the number of words. Next line contains N space-separated words. Output: Print the all the extracted digits separated by a space. Constraints: 1 ≤ N ≤ 50 It is guaranteed that at least one digit will be present in the entire input. Sample Input: 3 1 L0v3 Dcoder Sample Output:  1 0 3

input()
for s in input():
  if s.isdecimal():
    print(s, end=' ')

How do you rate this article?

3


Lochard
Lochard

20240228 Arrived in the UK for about 2 week. All my fears persist. Some are even getting worse. https://github.com/locharp/asylum_diary/


As a newbie programmer
As a newbie programmer

Sharing entry level codes. My snippets on GitHub https://github.com/locharp/code-snippets

Publish0x Publish0x

Reward the author with $0.01 in crypto, and earn yourself as you read!

20% to author / 80% to me.
Rewards are FREE. Publish0x pays them, not you.

Page not displaying correctly?