python - Not making integer inputs -


this question has answer here:

i want way user not make integer input using function:

x = input("whats name?")  while x == int: y = input("why there number in name? please re enter name") 

but not work. idea why?

improving in @persian_dev's answer -

def check_name(string):     char in string :         try:             int(char)             return false         except:             continue     return true 

this traverse string, try convert each character int , return false on first success in doing so.


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -