Question: this is my code in python for making a program to generate letters for a 7 digit phone number, except zero and one , if
this is my code in python for making a program to generate letters for a 7 digit phone number, except zero and one , if you type a phone number with zero or 1 in it , will give you a message that says :Invalid Entry,criteria (must be all integers 7 digits without any 0 or 1 my code work well, except when i enter zero as the 7th digit , i get error message , while when i enter 1 or zero as 1st or 2nd or third or 4th or 5th or sixth digit everything is fine , my invalid criteria message get printed which means works fine can you fix my error. it is in line 59 and 15 not sure what i need to change can you figure it out and can you show me your output after you fix it by entering phone number 2323230 """Name:IhabAtouf Date: 02/09/2023 CIS 131 PROGRAM : to generate letters codes for 7 digits phone number showing all the possibilities using dictionaries and lists capabilities """ # main function with the while condition true by default containing the dictionary of numbers with the list of letters def main(): while True: tele = {2: ['A', 'B', 'C'], 3: ['D', 'E', 'F'], 4: ['G', 'H', 'I'], 5: ['J', 'K', 'L'], 6: ['M', 'N', 'O'], 7: ['P', 'R', 'S'], 8: ['T', 'U', 'V'], 9: ['W', 'X', 'Y']} phone_number = tele_number() words = code_generator(tele, phone_number) codes(words) def tele_number(): # while loop true by default with try and except for data validation while True: try: phone_number = [int(i) for i in # trying for only integers input('Enter 7 digit phone number (2-9) to generate code')] # checking if the phone number equal to 7 digits if len(phone_number) == 7: # then checking if zero and one in phone number if 0 or 1 in phone_number: # the data validation error message print('Invalid Entry,criteria (must be all integers 7 digits without any 0 or 1)') continue else: break else: # error message print('Invalid Entry,criteria (must be all integers 7 digits without any 0 or 1)') except: # error message print('Invalid Entry,criteria (must be all integers 7 digits without any 0 or 1)') # prints specific error return phone_number # returns phone number # generating the code of letters matching the numbers entered def code_generator(tele, phone_number): words = [] for a in range(3): for b in range(3): for c in range(3): for d in range(3): for e in range(3): for f in range(3): for g in range(3): word = tele[phone_number[0]][a] + tele[phone_number[1]][b] + \ tele[phone_number[2]][c] + tele[phone_number[3]][d] + \ tele[phone_number[4]][e] + tele[phone_number[5]][f] + \ tele[phone_number[6]][g] words += [word] return words # printing the generated codes def codes(words): row = 20 # number of rows per line for i in range(0, len(words), row): line = words[i:i + row] print(line) main()
here is a screenshot of the output

Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
