python 2.7 - What is the most efficient way of turning this list into a string? -


i'm trying create string consisting of elements dictionary value.

for line in dictionary:     print 'category'.format(line['categories']) 

this result of running code above:

category = [[u'cafes', u'cafes'], [u'pakistani', u'pakistani'], [u'halal', u'halal']] category = [u'american (new)', u'newamerican'], [u'desserts', u'desserts']] 

when use this:

for x in line['categories']:     cat =', '.join(x)     print cat 

this result:

cafes, cafes pakistani, pakistani halal, halal  american (new), newamerican desserts , desserts 

what i'm trying achieve :

'cafes, cafes, pakistani, pakistani, halal, halal' american (new), newamerican, desserts , desserts 

you can this:

ss = '' x in line['categories']:     cat =', '.join(x)     ss += cat  print ss 

Comments

Popular posts from this blog

java - Spring Data JPA: Why findOne(id) executing delete query internally? -

python - Mongodb How to add addtional information when aggregating? -

java - Incorrect order of records in M-M relationship in hibernate -