in pyhton:
This function will ask the user for a string. It will check to see if the inputted string contains only digits and all the digits are less than 6. If they aren’t ask the input to try again and keep asking until they get correct
def get_input():
def get_input(): s = input("Enter input string: ") while True: flag = True for x in s: if int(x)>=6: flag = False break if flag: return s s = input("Enter input string: ") # testing print(get_input())
Get Answers For Free
Most questions answered within 1 hours.