Official

A - Secret Numbers Editorial by en_translator


If you are new to learning programming and do not know where to start, please try Problem A “Welcome to AtCoder” from practice contest. There you can find a sample code for each language.
Also, if you are not familiar with problems in programming contests, we recommend you to try some problems in “AtCoder Beginners Selection” (https://atcoder.jp/contests/abs).


It is sufficient to find the string obtained by extracting the digits in \(S\).

For example, the following algorithm achieves the goal:

  • Let \(T\) be an empty string.
  • From the first character of \(S\) in order, do the following:
    • If that character is a digit, append it to the end of \(T\).
  • The resulting \(T\) is the sought string.

The problem can be solved by properly implementing this algorithm.

Sample code (Python3)

s = input()
t = ""
for c in s:
    if c.isdigit():
        t += c
print(t)

Sample code (Python3)

print("".join(filter(str.isdigit,input())))

posted:
last update: