Dec-03-2018, 12:49 AM
Hi, thank you for taking the time to look over my code and offering good sugestions;
I'm just new at python, so I am not sure I'm understanding or following advice given
to me to the tee, however with your reply, I think I understand it to be to work
from one list or tuple at the begining when setting up the matching of numbers to letters.
So I rewrote the script, to eleiminate all the redundant tuples, in the begining of the
script, and removed the variable reassignments in the mid section, so as to output
working with index positions from a list directly.
Comparing this script with the one I originally wrote should clarify
what I'm trying to convey.
Thanks for your helpful reply.
I'm just new at python, so I am not sure I'm understanding or following advice given
to me to the tee, however with your reply, I think I understand it to be to work
from one list or tuple at the begining when setting up the matching of numbers to letters.
So I rewrote the script, to eleiminate all the redundant tuples, in the begining of the
script, and removed the variable reassignments in the mid section, so as to output
working with index positions from a list directly.
Comparing this script with the one I originally wrote should clarify
what I'm trying to convey.
Thanks for your helpful reply.
import os import os class klass: "docstring" def_int-self: self.attribute="var" if len (self.attribute)<2: pass print("") list_tuple=[("","",""),("","",""),("a","b","c"),("d","e","f"), ("g","h","i"),("j","k","l"),("m","n","o"), ("p","q","r","s"),("t","u","v"),("w","x","y","z")] print("");print("");print("This program will return all the letter conbinations") print( "that are available on the modern phone") print("You just type in a seven digit number and let the program display") print("all the letter conbinations that make up that number Enjoy");print("") flg=0 quit=0 while quit==0: list_numbers=[] list_cnvrt=[] cont=0 while cont==0: print("") print (" Enter (0) to exit out of the program");print ("") try: phone_number=input("Enter a 7 digit phone number (NO spaces)>> ") dummy=int(phone_number) if (phone_number)=="0": flg=1 break elif len(phone_number)< 7: print("") print ("Do not enter less than (7) digits") elif len(phone_number)>7: print("") print ("Do not enter more than (7) digits") else: cont=1 except: print("") print ("Enter numbers only no letters or special characters") for number in (phone_number): list_numbers.append(number) if flg==1: break print("") print (list_numbers) for number in (list_numbers): if number =="0": list_cnvrt.append(list_tuple[0]) if number=="1": list_cnvrt.append(list_tuple[1]) if number=="2": list_cnvrt.append(list_tuple[2]) if number=="3": list_cnvrt.append(list_tuple[3]) if number=="4": list_cnvrt.append(list_tuple[4]) if number=="5": list_cnvrt.append(list_tuple[5]) if number=="6": list_cnvrt.append(list_tuple[6]) if number=="7": list_cnvrt.append(list_tuple[7]) if number=="8": list_cnvrt.append(list_tuple[8]) if number=="9": list_cnvrt.append(list_tuple[9]) print("") print (list_cnvrt) cnt=1 for A in (list_cnvrt[0]): for B in (list_cnvrt[1]): for C in (list_cnvrt[2]): for D in (list_cnvrt[3]): for E in (list_cnvrt[4]): for F in (list_cnvrt[5]): for G in (list_cnvrt[6]): print ("(",(cnt),") ",(A)+(B)+(C)+(D)+(E)+(F)+(G)) print("") cnt=cnt+1