python too many values to unpack error and blank output
Question: I lost my previous account id so I am starting new.

    
    
    templist=[]
    temps1=[]
    templist2=[]
    tempstat1={}
    station1={}
    station2={}
    import os.path
    
    
    
    def main():
    
    #file name=animallog.txt
    
    endofprogram=False 
    try:
        filename=input("Enter name of input file >")
        file=open(filename,"r")
    except IOError:
        print("File does not exist")
        endofprogram=True
    count=0
    count2=0
    
    for line in file:
        line=line.strip('\n')
    
        if (len(line)!=0)and line[0]!='#':
    
            (x,y,z)=line.split(':')
            templist.append((x,y,z))
            record=(x,z)
            temps1.append(record)
    
            for x,y in record:
    
                if x in station1 or station2:
                    if y=='s1':
                        station1[x]=station1[x]+1
                    elif y=='s2':
                        station2[x]=station2[x]+1
    
                elif x not in station1 and station2:
                    if y=='s1':
                        station1[x]=1
                    elif y=='s2':
                        station2[x]=1
    
    
    main()
    

Anyways guys. I wrote this program. It is basically reading a file that has
info like this-> (animal:date:station number)

    
    
    a01:01-24-2011:s1
    
    a03:01-24-2011:s2
    
    a03:09-24-2011:s1
    

I am trying to count which animal goes to which station and how many times. I
do not want an answer from you experts but just need to know what this ERROR
means-

    
    
    File "/Applications/Wing101.app/Contents/MacOS/src/debug/tserver/_sandbox.py", line 58, in <module>
    File "/Applications/Wing101.app/Contents/MacOS/src/debug/tserver/_sandbox.py", line 39, in main
    
    builtins.ValueError: too many values to unpack (expected 2)
    

Thank you :)

**EDIT--**

changed `for x,y in record:` _TO_ `for x in record:`

But it prints `{}` when I try to print `station1` and `station2`

Why is it printing blank dictionaries for `station1` and `station2`?


Answer: `record` is a 2-tuple of strings. By iterating over `record` specifying a
2-tuple you are attempting to split each of these strings into 2 variables.

**This will not work unless they are two-character strings.**

Perhaps you meant to iterate over `temps1` instead?

