User Profile

Collapse

Profile Sidebar

Collapse
emokoena
emokoena
Last Activity: Nov 16 '11, 08:45 AM
Joined: Aug 18 '11
Location:
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • emokoena
    replied to How to read specific item in a list
    hi dwblas;

    I'm really am loosing my mind now. my code is only able to display the first entry, from there my if statement only evaluates to false for all other entries. please correct my code:

    #Choice 2 - Display Balances
    elif choice == "2":

    lists = []
    infile = open('emp_data. dat', 'r')
    lists = cPickle.load(in file)
    ...
    See more | Go to post

    Leave a comment:


  • emokoena
    replied to How to read specific item in a list
    All your suggestions have been invaluable and I have gotten someway but when I cPickle the file I fail to read the contents back as a list
    Code:
    #Choice 2 - Display Balances
        elif choice == "2":
            
            lists = []
            infile = open('emp_data.dat', 'r')
            #inlist = cPickle.load(infile)
            while 1:
                try:
                    lists.append(cPickle.load(infile))
    ...
    See more | Go to post
    Last edited by bvdet; Aug 27 '11, 02:47 PM. Reason: Add code tags

    Leave a comment:


  • emokoena
    started a topic How to read specific item in a list

    How to read specific item in a list

    I have created a list and would like to read specific items in it, I only can read 1

    Code:
    import cPickle, sys, shelve
    
    ## open file that stores scores
        
    choice = None
    employees = []
    while choice != "0":
    
        print \
                """
                411 TUCKSHOP
    
                OPTIONS:
                0 - Exit
                1 - Employee:
    ...
    See more | Go to post
    Last edited by Niheel; Aug 18 '11, 07:48 AM.
No activity results to display
Show More
Working...