I am trying to break a for loop that checks reads lines in another module. I notice that this function runs through every line of code in the module, but it only returns the boolean for the last line... how can I stop the loop as soon as it sees a false WITHOUT USING the break function? You don't have to worry about opening the file, I am capable of doing that
read_lines = file_handle.readlines()
for next_line in all_lines:
check = next_line[0]
if (check == ' '):
result = False
else:
result = True
return result
breakreturn False if check == ' ' else Truereturn Falsewill do the job.