I have a list with data that I want to go through with a for loop and put that data in a variable.
I am using the following code:
from Read_element_IDs import elementID
element_list = elementID()
#Comprueba importación de la lista print element_list
input_file_path = "A350-900_SMM10_I4_Exceedance_LCs_Step_7_FS_LHS.f06"
output_file_path = "EXTRACTION_FORCES_CRODS.txt"
with open(input_file_path, "r") as in_file, \
open(output_file_path, "w") as out_file:
i = 0
for i in element_list:
element_id = element_list[i]
for line in in_file:
#element_id = "55100515"
if line[:26] == " ELEMENT-ID =" + element_id:
out_file.write(line)
for line in in_file:
if line[0] == "1":
break
out_file.write(line)
break
else:
print("Element was not found")
I get an error in element_id = element_list [i] element_id = element_list [i] TypeError: list indices must be integers, not str
I do not understand why he is not taking i as a whole
How do I resolve it?