Problem with loop and .txt
I'm trying to create a program that executes commands within a loop from time to time. I wanted to create this alternation by using a .txt file, in which a number (number 1) is continuously written. So when the number is written a total of times (45 or 60 for example), the code performed a function, like this: if count.read == "1" * (45 or 60): print ( "hello") I noticed that, however, it was printed "hello" only at the achievement of 45 numbers 1 written. I thought I was wrong writing "1" * (45 or 60) so I wrote if count.read == "1" * 45: print ( "hello") if count.read == "1" * 60: print ( "hello") But still I print bye only at 45 and not at 60. Below is a complete example of what I've tried: import os localpath = (os.path.join (os.environ ['USERPROFILE'], "Documents \\ AppNanaBot")) def write_count_a (string): count = open (localpath + "\\ count.txt", "a") count.write (string) def write_count_w (string): count = open (localpath + "\\ count.txt", "w") count.write (string) def into_the_breach (): print ( "hello") write_count_w ( "") while True: write_count_a ( "1") count = open (localpath + "\\ count.txt", "r") if count.read () == "1" * 45: into_the_breach () if count.read () == "1" * 60: into_the_breach () print ( ".....")