# Author: Rob Kremer """ Asks for a valid phone number until one is entered. Valid phone numbers are 7 digits long, cannot have the first digit 0, and may contain embedded blanks or dashes. """ repeat = True while repeat: repeat = False phoneNum = input("Entry a valid phone 7-digit phone number: ") digitCount = 0 first = True for c in phoneNum: legalDigit = ((first and c>="1") or (not first and c>="0")) and c <="9" if legalDigit: digitCount += 1 if not (legalDigit or c==" " or c=="-"): repeat = True break; first = False if digitCount!=7: repeat = True print("Thank you; valid phone number entered.")