How to concatenate non string into list | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How to concatenate non string into list

https://code.sololearn.com/ceAVbE6dNX8Q/?ref=app Im getting below error and please let me know how to convert data from csv into list. TypeError: can only concatenate str (not "list") to str

18th Aug 2018, 8:04 AM
Raj Charan
3 Answers
+ 7
added some lines to create the Book1.csv file and write two lines into it your problem in the last for loop was that you were attempting to concatanate string with list when you read lines from csv a which look like this: |first|row| |second|row| the data is loaded like this: data = [ ['first', 'row'], ['second', 'row'] ] so one thing you can do is to join the sub-lists which will generate from ['first', 'row'] this string: 'first row' https://code.sololearn.com/cXv9A0uaKL5s/?ref=app
18th Aug 2018, 8:37 AM
Burey
Burey - avatar
0
i tried in my computer and got below error "TypeError: can only concatenate str (not "list") to str"
18th Aug 2018, 8:17 AM
Raj Charan
- 1
That's because you have the file "Book1.csv" on your computer. The program has 2 errors
18th Aug 2018, 8:34 AM
Dlite
Dlite - avatar