0
def clock():
    import time
    m = 0
    s = 0
    while(True):
        if((m<60) and (s<60)): print(m,":",s)
        elif(s==60):
            s == -1
            m += 1
        elif(m==60):
            print("It's been 1 hour m8")
            break
        s += 1
        time.sleep(1)

Result is, it counts until 0:59 then stops. It suppose to go until 59.59. I want to understand the fundemantal looping mistake which i did in here, thanks.

4
  • 2
    s == -1 just compares s to -1, then ignored the result. Presumably you meant s = -1, and we can just close this as a typo? Commented Jun 6, 2018 at 0:42
  • How i can close this ? I cant delete it, thank you for answer also Commented Jun 6, 2018 at 0:50
  • You don’t have to delete it; people who stop by should see that it was just a typo and take care of closing it. (I think new users who delete too many questions get throttled in asking new questions, so it’s better to let it get closed—but I’m not actually sure about that; check the help center if you’re worried.) Commented Jun 6, 2018 at 0:53
  • Thank you, alot of peoples on this site actually very rude to newbies, i mean i want to learn something very complex, and searching for help but peoples instead of giving the answer write 2 paragraps of how i typed things wrong or missed a charecter in my question etc. Commented Jun 6, 2018 at 17:24

1 Answer 1

2
s == -1

Does nothing here. Change it to

s = -1
Sign up to request clarification or add additional context in comments.

2 Comments

Oh my god, how did i missed that. i havent sleep for long time, i guess this is why its not good to code in late of night. Its embarissing
@Lichtspielhaus: I suggest to use Pycharm IDE, it will highlight this line for statement seems to have no effect

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.