line = input("> ") L = len(line) indigits = False digitstring = "" for i in range(L): if not line[i].isdigit() and not indigits: continue if not line[i].isdigit() and indigits: indigits = False print(digitstring) digitstring = "" continue indigits = True digitstring = digitstring + line[i] if indigits: print(digitstring)