简体   繁体   中英

Python - prime lister not displaying results or any errors

This is just a small segment of my code but I believe this is the part not working. So the user takes a low and high and finds all the prime number inbetween. But when I run this in IDLE not only is there no response, but there are no errors?! Can somebody please help.

^^^^^^ THIS WAS SOLVED THANKS GUYS ^^^^^^

New Question!

How would I change rangemax to make this print infinitly?

print('Prints all prime numbers between certain numbers.')    
rangemin = rangelowdef()
rangemax = rangehighdef() 

if rangemax != 'inf':
    for num in range(rangemin, rangemax + 1):
        if num > 1:
            for i in range(1, num):
                if num%i == 0:
                    break

            else:
                print(num)

num % 1 is always 0. That is because it is an integer (from the range function). So the loop breaks immediately and nothing gets printed.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM