Q:

generate md5 of list values in python

i have a list named as abc which have data like this :
{'devicetype': ['nokia'],'userid': ['1234'], 'year': ['2013']}

Now i have to generate the md5 of the values like nokia , '1234' , '2013'
for this i had taken these value in variable like this
 devicetype = abc['devicetype']
 userid = abc['userid']
 year = abc['year']

after that i tried to use md5 to generate a hash like this
  authvalue = hashlib.md5()
  authvalue.update(devicetype+userid+year)

it gives me an error "must be string or buffer, not list" 
i know this will accept just string . but how can i generate the md5 of these list value?

A:

Martijn Pieters' answer is basically correct, you have lists of a single element. If you have a big dictionary though, manually adding [0] to each entry might be a pain. So instead you can use map() and reduce() to do that for you.
If d is your dictionary with key-value pairs as above, you can do:
values = map(lambda x: x[0], d.values())

d.values() is just a list of the values of your dictionary (in your case, a list of 1-element long lists):
[['1234'], ['nokia'], ['2013']]

By mapping that lambda function to each one of them you get rid of the inner list:
['1234', 'nokia', '2013']

Then you can get the concatenation of all strings by reducing that list:
concat = reduce(lambda x, y: x + y, values, "")

So concat will be:
'1234nokia2013'

which then you can feed to your hashing function.

