Home > Software design >  I am having a problem of this python code not stopping when it is conditioned to stop. why is it not
I am having a problem of this python code not stopping when it is conditioned to stop. why is it not

Time:01-09

I am running all of this on a raspberry pi 4 model B with 8 gigs ram

import time

#sets variables and inputs
i = 0
meow = True
print("How many :")
runtimes = input("reo ")

#the main loop
while meow == True:
    i=i 1
    print(i)
    time.sleep(1)
    if i == runtimes :
        print("stopping")
        meow = False

CodePudding user response:

Change this: runtimes = input("reo ")

To this: runtimes = int(input("reo "))

What is currently happening is if you were to enter a 1 the value of runtimes would be "1"

When i=1 and this is ran if i == runtimes : It would be checking to see if 1 == "1" which would return False

  •  Tags:  
  • Related