The following code work but it's little bit messy and most of IDE show an error for undefined variable => "myFile" even if the code works.
i = 0
block = False
while i < 10:
if block == True:
myFile.write("End of a Turn.")
block = True
myFile = open("path/of/my/file/"+str(i)+".txt", "w")
myFile.write("The turn begin.")
i += 1
What I want to do is to "pre-define" the variable before the first assignment:
#myFile = SOMETHING_THAT_DOES_NOT_RUIN_THE_FOLLOWING_CODE
myFile = None #RESOLVE
i = 0
block = False
while i < 10:
if block == True:
myFile.write("End of a Turn.")
block = True
myFile = open("path/of/my/file/"+str(i)+".txt", "w")
myFile.write("The turn begin.")
i += 1
To avoid some IDE comprehension problems.
Ty for help,
S.