I tried to take an input from the command line by passing a file and storing it in an array.
I know my input is two words separated by white space, so I tried
for line in sys.stdin:
a=line.split() #to split the 2 words separated by white space into 2 list elements
print a # just to debug my code
edges(a, a) #calling the function edges
IndexError: list index out of range
Try specifying the index into which you are inputting the word. This will keep the list/array from overflowing and causing "index out of bounds" error.
EDIT I see you are trying to store the first element as the key and then value. Please use a counter such as 'k' and 'v' to keep track and avoid overflows.
Hope this helps,