Jul-31-2023, 02:27 PM
Hi All,
first apologizes for my poor scripting - I am a beginner.
I have found lots of information about my doubt but none could actually solve my problem:
About my code: the function generator() will provide me a str number and the function Validator() will run thru a txt file to confirm if such number was already given. If yes, it will increment and return a value into a "control" variable loop_valve, and if no, it will change the w_loop variable to 2 and break the WHILE loop in the main function.
What is my problem: Because of the WHILE condition I need to be able to increment =+1 on both variables w_loop and w_loop, so that I will be able to (1) break the while loop and/or (2) stop the script after a certain condition is met.
Regardless of where I declare the global variables, both underlying variables' values are always changing to the initial value after the MAIN <> FUNCTION iteration. I need to be able to increment those variables freely so that I can control the number of runs of each time it passes thru a function.
first apologizes for my poor scripting - I am a beginner.
I have found lots of information about my doubt but none could actually solve my problem:
About my code: the function generator() will provide me a str number and the function Validator() will run thru a txt file to confirm if such number was already given. If yes, it will increment and return a value into a "control" variable loop_valve, and if no, it will change the w_loop variable to 2 and break the WHILE loop in the main function.
What is my problem: Because of the WHILE condition I need to be able to increment =+1 on both variables w_loop and w_loop, so that I will be able to (1) break the while loop and/or (2) stop the script after a certain condition is met.
Regardless of where I declare the global variables, both underlying variables' values are always changing to the initial value after the MAIN <> FUNCTION iteration. I need to be able to increment those variables freely so that I can control the number of runs of each time it passes thru a function.
def Validator(res_01,f,loop_valve):
with open('input.txt') as f:
if str(res_01) in f.read():
loop_valve =+1
return loop_valve
ielse:
w_loop = 1
#
if __name__ == "__main__":
for z in range(50):
res01 = generator() ### string number function
global loop_valve
loop_valve =1
w_loop == 0
while w_loop == 0: ### Repeat until a certain condition is met
if loop_valve == 100:
break
print("[VALVE-BREAK]")
else:
Validator(res_01,f,loop_valve)
print("[INFO]: end")thank you in advance :)
