I was trying to run a code that I wrote the code reads lines on txt file so my text file looks like (i've 20 lines)
['39', '40', '39', '38', '35', '38', '39', '39', '42', '37', '40', '41', '37', '39', '39', '40', '38', '40', '39', '40']
['39', '40', '39', '38', '36', '39', '40', '39', '42', '38', '40', '41', '38', '39', '39', '40', '38', '40', '39', '41']
['39', '40', '40', '38', '36', '39', '40', '39', '43', '38', '40', '41', '38', '39', '39', '40', '38', '40', '39', '41']
i wrote this script to have a new file that looks like this
39 40 39 38 35 38 39 39 42 37 40 41 37 39 39 40 38 40 39 40
39 40 39 38 36 39 40 39 42 38 40 41 38 39 39 40 38 40 39 41
39 40 40 38 36 39 40 39 43 38 40 41 38 39 39 40 38 40 39 41
the script that i wrote is this one
#!/usr/bin/python3
# -*- coding: utf-8 -*-
fichier=open("data.txt", "r")
#resultat=open("data_entier.txt", "w")
j=0;
while j < 20:
lignes= fichier.readline()
for i in range(len(lignes)):
lignes[i] = int(lignes[i])
print(lignes))
j+=1
fichier.close()
the error that I get is this one
ValueError: invalid literal for int() with base 10: '['