basskiller
basskiller

Reputation: 85

I want make list with django

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?

Upvotes: 1

Views: 30

Answers (1)

willeM_ Van Onsem
willeM_ Van Onsem

Reputation: 477210

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'.

Upvotes: 1

Related Questions