Python: Can someone help me debug this error? [newbie] -


i have piece of code that's meant compare 2 lists (which read csv files) , return items in , not in b , vice versa. here's i've got:

import csv  #open csv's , read first column product ids variables pointing lists open("a.csv", "rb") f:      = {row[0] if len(row) else default_value row in csv.reader(f)} open("b.csv", "rb") g:      b = {row[0] if len(row) else default_value row in csv.reader(g)}   #create variables pointing lists unique product ids in , b respectively   in_a_not_b = a-b  in_b_not_a = b-a   print len(in_a_not_b), " items in missing b", in_a_not_b print len(in_b_not_a), " items in b missing a", in_b_not_a   print "done!"  

it used run fine, until got error:

traceback (most recent call last):   file "c:/.../python - comprare 2 lists", line 7, in <module>     b = {row[0] if len(row) else default_value row in csv.reader(g)}   file "c:/.../python - comprare 2 lists", line 7, in <setcomp>     b = {row[0] if len(row) else default_value row in csv.reader(g)} nameerror: global name 'default_value' not defined 

can please ? thanks!

you not have default_value variable.

just error says:

nameerror: global name 'default_value' not defined 

you should put like:

default_value = none 

above code.


Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -