编译此代码时出现此错误 "Time Limit Exceeded Your program took more time than expected."

I am getting this error while compiling this code "Time Limit Exceeded Your program took more time than expected."

我在编译这段代码时不断收到这个错误

超过时间限制

您的程序花费的时间超过 expected.Time 超出限制 预期时间限制 1.02 秒 提示:请优化您的代码并重新提交

##把函数写完整

    def isPrime(number):

        for i in range(2, number):
            if (number % i) == 0:
                return False
                break
        return True


       #Driver Code Starts.


    import math



    def main():
        testcases = int(input()) #testcases
        while(testcases > 0):
            number = int(input())
            print(isPrime(number)) 
            testcases -= 1
    


     if __name__=='__main__':
        main()

函数 isPrime 出错请给我解决方案

替换

for i in range(2, number):

for i in range(2, (number/2)+1):

此外,此代码中没有使用 break,因此也将其删除。