modifying conditions in for in python
===

hey this is a code that works fine. i am using in a bigger code and the program gives quick answer for like 999999 or 9999999.

    prime=[2,3,5]
    f=7
    def next_prime(f): #whenever called, measures the next prime of the list and returns it
        j=len(prime)
        while j==len(prime):
            for x in prime:
                if f%x==0:
                    f+=2
                    break
            else:
                prime.append(f)
        return f


but if i modify the code a little because i want add the condition that x should be less than f**.5 , the program doesn't any more give result.
prime=[2,3,5]

    f=7
    main=[]
    power=[]
    def next_prime(f):
        j=len(prime)
        while j==len(prime):
            for x in prime:
                if (x<int(f**.5)+1) and f%x==0:
                    f+=2
                    break
            else:
                prime.append(f)
        return f


where is the mistake taking place???