Jun-21-2017, 10:10 PM
Dear Python Users,
Please, help to identify where is my mistake in the code. What I am trying to do is to write the info (lines 1-3) into txt file.
However, when I run this code the python never executes it, it continues to run forever.
Please, help to identify where is my mistake in the code. What I am trying to do is to write the info (lines 1-3) into txt file.
However, when I run this code the python never executes it, it continues to run forever.
tsv = [20, 31, 52, 73] forecast = [0, 20, 31, 52] forecast_error = [0, 0, 0, 0] for x in range(0, len(tsv)): forecast_error[x] = tsv[x] - forecast[x] F1 = open('C:\\Users\\Documents\\Exercise2\\fixeddata.txt', 'w') #example line #37 52 352 # 111111111122222222222 #0123456789012345678901234567890 for x in range(0, len(tsv)): strrec = "" #handle tsv str1 = str(tsv[x]) while len(str1) < 10: str1 = str1 + "" strrec = strrec + str1 #handle forecast str1 = str(forecast[x]) while len(str1) < 10: str1 = str1 + "" strrec = strrec + str1 #handle forecast error str1 = str(forecast_error[x]) while len(str1) < 10: str1 = str1 + "" strrec = strrec + str1 strrec = strrec + "\n" F1.write(strrec) F1.close()