Magna Wise
Magna Wise

Reputation: 149

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)

Upvotes: 0

Views: 64

Answers (1)

Mathias711
Mathias711

Reputation: 6668

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.

Upvotes: 3

Related Questions