q = [] num = ["1","2","3","4","5","6","7","8","9","0"] while True: dat = float(input("Enter Name: ")) if dat == "*": print(q.pop(0)) if dat in num : break else: q.append(dat) #the program only terminates when inputted 0 to 9 numbers but I want it to terminate if any numbers are inputted.