Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

I am having a problem of this python code not stopping when it is conditioned to stop. why is it not stopping?

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

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading