Dec-05-2018, 12:14 AM
(This post was last modified: Dec-05-2018, 12:14 AM by hobbyprogrammer.)
Thank you, guys for your helpful suggestions, I'm not proficient enough in programming
yet, to be able to read codes that is brought to my attention, from others, so please
excuse any code structure that I may leave out, as I'm trying to learn at my own
pace and methods of script writing.
However The suggestion about minimizing the codeing between 57 and 77, has spurred me on
to experimenting with ways to accomplish this. Thankyou for the scriptings you shared
on how to do this, but as I said, I need to work at this at my own level of understanding
so I took your suggestion about reducing that block of code, and this is what I
was able to come up with. This is a learning process for me so please understand, it is
not the substitute codes you showed, but I neded to come up with something on my own,
as all of this is learning exercises for me in python programming.
However I will look at learning how to use the (product function) as you shared,
but for right now I'll just share what I understand at this point in the journey.
yet, to be able to read codes that is brought to my attention, from others, so please
excuse any code structure that I may leave out, as I'm trying to learn at my own
pace and methods of script writing.
However The suggestion about minimizing the codeing between 57 and 77, has spurred me on
to experimenting with ways to accomplish this. Thankyou for the scriptings you shared
on how to do this, but as I said, I need to work at this at my own level of understanding
so I took your suggestion about reducing that block of code, and this is what I
was able to come up with. This is a learning process for me so please understand, it is
not the substitute codes you showed, but I neded to come up with something on my own,
as all of this is learning exercises for me in python programming.
However I will look at learning how to use the (product function) as you shared,
but for right now I'll just share what I understand at this point in the journey.
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")] about=""" This program will return all the letter conbinations that are available on the modern phone You just type in a seven digit number and let the program display all the letter conbinations that make up that number Enjoy""" print(about) 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") elif (" ") in (phone_number): print("") print ("Do not enter any space characters") else: cont=1 except: print("") print ("Enter numbers only no letters or special characters") for number in (phone_number): number=int(number) print (number) list_numbers.append(number) if flg==1: break print("") print (list_numbers) for number in (list_numbers):#this is my understanding of how to minimize the (if) statements. routine starts here for compare in range(10): if (compare)==(number): list_cnvrt.append(list_tuple[compare])#routine ends here 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