Python Forum
Please, help to identify the mistake in the code
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Please, help to identify the mistake in the code
#1
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.

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()
Reply


Messages In This Thread
Please, help to identify the mistake in the code - by Alberto - Jun-21-2017, 10:10 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  identify not white pixels in bmp flash77 17 2,513 Nov-10-2023, 09:21 PM
Last Post: flash77
  [Solved] Please, help me find a simple mistake AlekseyPython 2 1,760 Jun-17-2021, 12:20 PM
Last Post: AlekseyPython
  [split] Could you please clarify where i did mistake also how run without admin right Abubakkar 1 1,799 Jun-14-2021, 09:32 AM
Last Post: Larz60+
  guys please help me , pycharm is not able to identify my xlsx file CrazyGreenYT7 1 2,025 Jun-13-2021, 02:22 PM
Last Post: Larz60+
  Need to identify only files created today. tester_V 5 4,662 Feb-18-2021, 06:32 AM
Last Post: tester_V
  Please help to me to find my mistake in code leonardin 2 1,851 Nov-29-2020, 04:17 PM
Last Post: Larz60+
  minor mistake in code for factorial spalisetty06 2 1,895 Aug-22-2020, 05:00 PM
Last Post: spalisetty06
  Simple mistake about for Nomatter 4 2,266 Jul-16-2020, 02:24 PM
Last Post: Nomatter
  Install Mistake jlerette5 1 1,909 Feb-18-2020, 12:19 AM
Last Post: jefsummers
  Need to identify sheet color in excel workbook chewy1418 2 2,532 Feb-14-2020, 03:26 PM
Last Post: chewy1418

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020