How to convert list to a string?


Warning: count(): Parameter must be an array or an object that implements Countable in /home/styllloz/public_html/qa-theme/donut-theme/qa-donut-layer.php on line 274
0 like 0 dislike
16 views
Need to translate a list into a string.
for row in data_body: print(row) data = ','.join(row)


However, I get the following error. Can't understand why:
[None, u'1516482864.000000', 627, 0, u'9227943', 41, 60.0, u 'transaction', u'+345348880', u'5000.00', u'345188435', 472, 1463, u'2018-01-20 21:12:19.019598', u 6be2d345dd43af6fc23', 6225064, u'222222222'] Traceback (most recent call last): File "app.py", line 72, in data = ','.join(row) TypeError: sequence item 0: expected string, NoneType found
by | 16 views

1 Answer

0 like 0 dislike
data = ','.join(str(i) for i in row)

if None should be removed
data = ','.join(str(i) for i in row if i is not None)
by

Related questions

0 like 0 dislike
3 answers
0 like 0 dislike
1 answer
asked Jun 10, 2019 by alekskondr
0 like 0 dislike
2 answers
0 like 0 dislike
1 answer
asked May 22, 2019 by vldanch
110,608 questions
257,187 answers
0 comments
40,796 users