def is_digit(s): flag = True for i in s: if not i.isdigit(): flag = False return flag s = "12345" print(is_digit(s))