Calculate the number of primes in a range I wrote some code to return how many prime numbers are in a specific range and what they are. It also tells you whether the number of primes is also a prime!

I feel like this seems like a fairly long winded approach for something that's probably very simple, can someone please tell me how I can improve this?

def prime_number():
    primes = []
    primes_2 = []
    low = int(input("What number would you like to start at? "))
    high = int(input("What number would you like to go up to? "))
    if int(low) == 1 and int(high) == 1:
        print("1 isn't a prime number dumb dumb")
    elif high &lt; 2:
        print("Don't be annoying")
    else:
        for x in range(int(low), int(high)):
            for i in range(2, x):
                if (x % i) == 0 and x != i:
                    break
                elif (x % i) == 1 and i &lt;= (x - 2):
                    continue
                elif (x % i) == 1 and i == (x - 1):
                primes.append(x)
            x = x + 1
        print("The number of prime numbers is: ", len(primes))
        for y in range(2, int(low)):
            for z in range(2, y):
                if (y % z) == 0 and y != z:
                    break
                elif (y % z) == 1 and z &lt;= (y - 2):
                    continue
                elif (y % z) == 1 and z == (y - 1):
                    primes_2.append(y)
            y = y + 1
        if int(len(primes)) in primes or int(len(primes)) in primes_2:
            print("Huh, fancy that!", len(primes), "is also also a prime number!")
        print("The prime numbers are: ",primes)
Welcome to Code Review! Here are some suggestions.

Naming

Choose a better name than primes_2. I'm not clear on what this variable does.

Write some documentation

...in triple quotes at the top of your function. Describe its inputs and outputs.

Separate user input from processing

Put your calculation code in a separate function from your user input and output code.

Validation

If the user enters invalid input, consider looping until the input they provide is valid. Or, at least - return out of the function if it's invalid, instead of having a large else covering the rest of your code.

Increment-and-assign

Use x += 1 instead of x = x + 1.

Formatted output

Consider using this form instead:

print(f'Huh, fancy that! {len(primes)} is also a prime number!')