Reputation: 2794
I have following list example
['Justice league', 'Avenger']
Now the problem i facing to convert list to unicode list
Unicode list example is
[u'Justice league', u'Avenger']
How can I achieve this? thank you for your response.
Upvotes: 4
Views: 9528
Reputation: 11590
try applying unicode
to its elements
>>> lst=['Justice league', 'Avenger']
>>> map(unicode,lst)
[u'Justice league', u'Avenger']
Obviously we are talking about Python 2 only, since literal strings are unicode by default in Python 3
Have a look at this Q&A on the same subject
Upvotes: 6
Reputation: 11961
Use the built in unicode
function with a list comprehension:
x = ['Justice league', 'Avenger']
answer = [unicode(item) for item in x]
Upvotes: 2