I'm trying to insert a String into a list.
I got this error:
TypeError: can only concatenate list (not "tuple") to list
because I tried this:
var1 = 'ThisIsAString' # My string I want to insert in the following list
file_content = open('myfile.txt').readlines()
new_line_insert = file_content[:10] + list(var1) + rss_xml[11:]
open('myfile.txt', 'w').writelines(new_line_insert)
The content of myfile.txt is saved in "file_content" as a list. I want to insert the String var1 after the 10th line, thats why I did
file_content[:10] + list(var1) + rss_xml[11:]
but the list(var1) doesn't work. How can I make this code work? Thanks!