Nov-10-2018, 02:23 AM
Hi,
I'm learning python ver 3.(x) programming.
I have been developing a program to learn alot about list manipulation, so I'm currently working on a "phonelist"program, I have it working with all the features of inputing names and numbers, appending and saving to files, and doing search's by name or number, etc..
however one feature I havn't yet incorporated into it is the ability for the user to change the data in the list, to update the list with a changed name or number.
So I set out to work on subprograms, to learn the algorythm of accomplishing this feature, and I came up with a feature that works with limited ability, but it works good enough to be a standalone program in itself.
So I would like to share this subprogram with other beginners, for them to have fun learning with it and hacking it to make it work for there use.
As I said I'm only a beginner myself, so I know the code is not to professional standards, but I am only a hobbyist in programming, and I like to share the things I'm learninjg at the beginners level.
Thanks for understanding.
Here is the program:
I'm learning python ver 3.(x) programming.
I have been developing a program to learn alot about list manipulation, so I'm currently working on a "phonelist"program, I have it working with all the features of inputing names and numbers, appending and saving to files, and doing search's by name or number, etc..
however one feature I havn't yet incorporated into it is the ability for the user to change the data in the list, to update the list with a changed name or number.
So I set out to work on subprograms, to learn the algorythm of accomplishing this feature, and I came up with a feature that works with limited ability, but it works good enough to be a standalone program in itself.
So I would like to share this subprogram with other beginners, for them to have fun learning with it and hacking it to make it work for there use.
As I said I'm only a beginner myself, so I know the code is not to professional standards, but I am only a hobbyist in programming, and I like to share the things I'm learninjg at the beginners level.
Thanks for understanding.
Here is the program:
import os class klass: '"docstring'" def_init_(self): self.attribute="var" if len(self.attribute) <2: pass print("") print ("Enter a subject you would like to build up a list for!") print("Ex. (name,city,state,number,team,job,friend,hobby...etc...)") print("In other words you'r making a (name list, hobby list or a job list etc...)") print("") userstart=input("subject to make a list for>> ") lista=[] flg=0 add=0 while flg==0: print ("Enter (exit) to exit") print("") user = input ("enter a, "+(userstart)+" >> ") print("") if user=="exit": flg=1 else: lista.append(user) add=1 chng=0 if add==1: print ("Here is your ,"+(userstart)+" list, to date, ") print("") print(" ROW ITEM") print("---------------------------") cnt=0 for item in lista: cnt+=1 print (" (",(cnt),") ",(item)) chk=0 ask=0 while ask==0: print("") print("Would you like to change an item in your, "+(userstart)+" list?") user=input("change and item? (Y) or (N) ") if user =="y": print ("") while chk==0: user=input("enter the row number to change that item ") try: user=int(user) row=0 for item in lista: chk=1 row+=1 ndx=lista.index(item) if row==(user): newndx=ndx chng=1 ask=1 except: print("") print ("Enter a row number from the list") if chk==1 and chng==0: print("") print("Choose a row number from the list") chk=0 elif user=="n": ask=1 else: print("") print("enter (y) or (n)") change=0 while change==0: if chng==1: print("") user=input("Enter a new item to take the place>> ") print("") lista[newndx]=(user) cnt=0 for item in lista: cnt+=1 print ("(",(cnt),") ",(item)) print("") print ("The change has been made thankyou") change=1 else: change=1 print("") print("Done")