It is necessary to get such a condition:
If the list has at least one letter print "Please enter a number!"
It is necessary to get such a condition:
If the list has at least one letter print "Please enter a number!"
It seems that this question does not correspond to the subject of the site. Those who voted to close it indicated the following reason:
def has_letter(items): return any(c.isalpha() for c in items) # Более привычный алгоритм: # def has_letter(items): # for c in items: # if c.isalpha(): # return True # # return False items = ['1', '3', '4'] print(has_letter(items)) # False items = ['у', '1', '3', '4'] print(has_letter(items)) # True items = ['f', '1', '3', '4'] print(has_letter(items)) # True items = ['у', '1', '3', '4'] if has_letter(items): print("Пожалуйста введите цифру!") num = None for letter in list: if letter.isalpha(): num = input("Пожалуйста введите цифру") break Further address to num , there value which you will enter into the console will be written.
In case you do not need to store / use the entered digit further, you just need to print the message to the console: replace num = input("Пожалуйста введите цифру") with print("Пожалуйста введите цифру") and delete the first line ( num = None ).
Source: https://ru.stackoverflow.com/questions/865177/
All Articles