I have a dictionary of lists as follows: 

```
{'banana': [1,2],
 'monkey': [5],
 'cow': [1,5,0],
 ...}

```

I want to write a csv that contains one number and word as follows: 

```
1 | banana
2 | banana
5 | monkey
1 | cow
5 | cow
0 | cow
...

```

with | as the delimiter. 

I tried to convert it to a list of tuples, and write it as follows: 

```
for k, v in dic.items():
    for ID in v: 
        rv.append((ID, k))

with open(index_filename,'wb') as out:
    csv_out=csv.writer(out, delimiter='|')
    csv_out.writerow(['identifier','descriptor'])
    for row in rv:
        csv_out.writerow(row)

```

but ran this error: 

```
a bytes-like object is required, not 'str'

```

Is there a more efficient way of doing this than converting to a tuple, and if not, what's wrong with my code? 

Thanks.