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 ( ".....")