Question: I have a file with questions and answers on the same line, I want to seperate them and append them to their own empty list but keep getting this error:  

`builtins.ValueError: need more than 1 value to unpack`

```
questions_list = []
answers_list = []

questions_file=open('qanda.txt','r')

for line in questions_file:
    line=line.strip()

    questions,answers =line.split(':')

    questions_list.append(questions)
    answers_list.append(answers)

```

Answer: 
This is probably because when you're doing the splitting, there is no `:`, so the function just returns one argument, and not 2. This is probably caused by the last line, meaning that you're last line has nothing but empty spaces. Like so:

```
>>> a = '   '
>>> a = a.strip()
>>> a
''
>>> a.split(':')
['']

```

As you can see, the list returned from `.split` is just a single empty string. So, just to show you a demo, this is a sample file:

> 
> 
> ```
> a: b
> c: d
> e: f
> 
> g: h
> 
> ```
> 
> 

We try to use the following script (`val.txt` is the name of the above file):

```
with open('val.txt', 'r') as v:
    for line in v:
        a, b = line.split(':')
        print a, b

```

And this gives us:

```
Traceback (most recent call last):
a  b

c  d
  File "C:/Nafiul Stuff/Python/testingZone/28_11_13/val.py", line 3, in <module>

    a, b = line.split(':')
e  f
ValueError: need more than 1 value to unpack

```

When trying to look at this through a debugger, the variable `line` becomes `\n`, and you can't split that.

However, a simple logical ammendment, would correct this problem:

```
with open('val.txt', 'r') as v:
    for line in v:
        if ':' in line:
            a, b = line.strip().split(':')
            print a, b

```
`line.split(':')` apparently returns a list with one element, not two.

Hence that's why it can't unpack the result into `questions` and `answers`. Example:

```
>>> line = 'this-line-does-not-contain-a-colon'
>>> question, answers = line.split(':')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: need more than 1 value to unpack

```