Home > Software design >  I want make list with django
I want make list with django

Time:11-23

category1 = ''
category1_tmp = ['a','b',c','d']
for n in category1_tmp:
    category1 &= n   '|'

django error : unsupported operand type(s) for &=: 'str' and 'str'

what i want : a|b|c|d

how can I solve?

CodePudding user response:

You can join the elements together with:

category1 = '|'.join(category1_tmp)

For a list ['a', 'b', 'c', 'd'] this will result in category1 = 'a|b|c|d'.

  • Related