python 2.7 - Is there a way to go back and edit the information the user entered? -


i have simple code written in python 2.7 ask users information, , exports information .csv file. once user inputs data, there way them go , edit entered after pressing enter? here have far:

def writer(): import csv  open('work_order_log.csv', 'a') f:     w=csv. writer(f, quoting=csv.quote_all)      while (1):         correct=true         employee=true         workorder=true         item=true         qty=true         process=true         date=true         time=true         while correct:             correct=false             employee=false             workorder=false             item=false             qty=false             process=false             date=false             time=false             employee=raw_input("1. enter name:")             workorder=raw_input("2. enter work order number:")             partnumber=raw_input("3. enter item number:")             qty=raw_input("4. enter quantity:")             process=raw_input("5. enter process:")             date=raw_input("6. enter date(mm/dd):")             time=raw_input("7. total time(hh:mm):")             needtocorrect=raw_input("is last entry correct? (if so, type 'y') if not enter number of field incorrect:")             if needtocorrect=="1":                 employee=true             elif needtocorrect=="2":                 workorder=true             elif needtocorrect=="3":                 item=true             elif needtocorrect=="4":                 qty=true             elif needtocorrect=="5":                 process=true             elif needtocorrect=="6":                 date=true             elif needtocorrect=="7":                 time=true             w.writerow([employee,workorder,item,process,qty,date,time,correct])  writer() 

after testing code, have found when enter number of incorrect field correction, shows in .csv file incorrect, still makes me go through entire loop fix errors. why this?

you can put of input while block:

while (1):     correct = true     while correct:         correct = false         employee=raw_input("enter name:")         ...          needtocorrect=raw_input("is last entry correct?(y/n):")         if needtocorrect == "n":               correct = true     w.writerow([employee,workorder,partnumber,process,qty,date,time,correct]) 

then if user notices incorrect, "n" prompt user return , retype fields. if want correct fields, similar, more complicated, method work fine.


Comments

Popular posts from this blog

ios - UICollectionView Self Sizing Cells with Auto Layout -

node.js - ldapjs - write after end error -

DOM Manipulation in Wordpress (and elsewhere) using php -