I have a python list that looks like that:
list = [u\'a\', u\'b\', u\'c\']
Now I want to encode it in UTF-8. Therefore I though I should us
>>> items = [u'a', u'b', u'c']
>>> [x.encode('utf-8') for x in items]
['a', 'b', 'c']
list[0]
is the first element, not a list. you are reassigning your list
var to a new value, the utf-8 encoding of the first element.
Also, don't name your variables list
, as it masks the list()
function.