number = "34e.l5p#" separators = "" for char in name: if name.isnumeric(): separators = separators + char print(separators) # .isnumeric() only prints the separators of the name(4.#)